ohmyzsh: [oh-my-zsh] Can't update: not a git repository.

Describe the bug

Every time I boot up the terminal I get the message [oh-my-zsh] Can't update: not a git repository. Is there anything to do about this?

Steps to reproduce

1.I open my terminal 2.[oh-my-zsh] Can't update: not a git repository. message pops up

Expected behavior

Usually when I open terminal it asks if I would like to update

Screenshots and recordings

Screen Shot 2022-04-15 at 6 43 43 PM

OS / Linux distribution

MacOS 12.3.1

Zsh version

5.8

Oh My Zsh version

N/A

Terminal emulator

terminal.app

If using WSL on Windows, which version of WSL

No response

Additional context

Also when I try to check for Oh My Zsh version it says <detached> ()

Screen Shot 2022-04-15 at 6 48 46 PM

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 24 (7 by maintainers)

Most upvoted comments

I had a similar problem this morning, seemed to be in a constant loop of wanting to install. I eventually broke out of it with:

xcodebuild -runFirstLaunch

In my case, it needed to authenticate with PIV card, which it finally prompted for.

On a Mac, if the xcode command-line license agreement has been updated and needs to be accepted, any tool that has dependencies on it can fail. In this case, the ‘git’ command that does the oh-my-zsh update checking is failing.

To solve, issue following and type ‘agree’ to accept the license terms:

sudo xcodebuild -license

This solved it for me.

Starting Xcode after updating and agreeing to the license fixed it for me.

The missing xcrun error is solved by running the command posted by Richard above:

xcode-select --install

Then you can re-run the git clone command above:

git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "${ZSH:-$HOME/.oh-my-zsh}"

After that, re-run zsh with exec zsh and you should be good to go.

I just had this error today in my MacBook. I found out that I had to agree to the new Xcode license terms

  1. sudo xcodebuild -license
  2. scroll down to the bottom of the license and type “agree”

then it still didn’t work but it warned that I had to reinstall something from Xcode xcodebuild -runFirstLaunch

that was the solution for me

On a Mac use sudo xcode-select -switch /Library/Developer/CommandLineTools after update.

It looks like the OMZ folder is missing the .git directory. Maybe it got deleted or something. Try reinstalling it by removing the directory and cloning it back in the same place:

NOTE: before running rm -rf "$ZSH" make sure the value of $ZSH is correct. It should point to the directory where you installed Oh My Zsh, which by default is at $HOME/.oh-my-zsh

rm -rf "$ZSH"
git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "$ZSH"

You should be able to update again after that.

Have you updated the OS since you installed the Xcode command line utilities? If so, reinstall:

xcode-select --install

Even if you haven’t, run that anyway just to verify they are current.

I just had this error today in my MacBook. I found out that I had to agree to the new Xcode license terms

  1. sudo xcodebuild -license
  2. scroll down to the bottom of the license and type “agree”

then it still didn’t work but it warned that I had to reinstall something from Xcode xcodebuild -runFirstLaunch

that was the solution for me

Right. This might not be a git problem if you had things workings. One way to check is: $ cd $ZSH $ git log

image

This fixes: [oh-my-zsh] Can't update: not a git repository.

Background: I’ve been using numerous instances of Xcode, and before the Xcode 14 update, I set the developer path in ZSH to be: /Applications/Xcode-13.3.1.app/Contents/Developer and I forgot about it. So after the update when the name of Xcode got changed to simply Xcode.app, ZSH did not know where to look for the xcode tools.

Running the command suggested above in this thread, has hinted me how to resolve the issue, here’s an excerpt:

git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "${ZSH:-$HOME/.oh-my-zsh}" xcrun: error: active developer path ("/Applications/Xcode-13.3.1.app/Contents/Developer") does not exist

Solution: And the solution was simple: sudo xcode-select --switch /Applications/Xcode.app/ - before running it, check how Xcode is called in the Applications folder on your machine 😃

That’s a lot of faith ZSH is set properly.

If anyone else is running into issues after the macOS 12.6 update, this worked for me:

I kept getting an error loop prompting me to install the Xcode command line tools. It would say it succeeded but then running git --version would throw a bunch of unintelligible nonsense and prompt me to install them again.

I ultimately used AppCleaner to locate all of Xcode’s settings folders and delete everything but the Xcode binary itself. I then opened the Xcode app and accepted the install prompts which fixed the CLI tools.

Then I reran the usual oh-my-zsh installer script and everything was dandy!