I tried to update my git version on Mac OS X 10.7, but it doesn't change the version.
It's still on 2.0.
If I run,
rm -rf /usr/local/git
rm /etc/paths.d/git
rm /etc/manpaths.d/git
the new version gets uninstalled, but the old one is still there (git is still a valid command).
How can I find the directory where this "ghost" version is installed?
To see where git is installed:
which git
See for instance those guides:
"Beginner's Setup Guide for Git & Github on Mac OS X"
"Install and Update to latest version Git on Mac OSX 10.10 Yosemite"
The location usually is:
/usr/local/git/bin/git
As mentioned in "Can't seem to uninstall git":
/opt/local/bin is the location of software installed by macports, so you'll want to run this:
sudo port uninstall git
If you see /usr/local/bin/git, that is likely a brew installation: see "Can't use homebrew installed git":
brew uninstall git
# make sure everything is alright, maybe brew will give you some hint
brew doctor
brew update
brew install git
# magic happen, brew will give you hint /usr/bin occurs before /usr/local/bin
# and recommend you run following command
brew doctor
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
Related
I am trying to install ruby 2.5.0 on my system (macOS High Sierra) using rbenv but i'm facing a weird issue as the brew instructions are out of date:
djeustinezzz:~ JUSTINE$ rbenv install rbx-2.5.0
ERROR: Rubinius will not be able to compile using Apple's LLVM-based
build tools on OS X. You will need to install LLVM 3.5 first.
TO FIX THE PROBLEM: Install Homebrew's llvm package with this
command: brew tap homebrew/versions ; brew install llvm35
BUILD FAILED (OS X 10.13.6 using ruby-build 20160130)
The version 3.5 of LLVM was deleted. After googling here is what i've done:
brew tap homebrew/homebrew-core
brew install llvm#3.7
But nothing changed.
Homebrew, rbenv and ruby-build are installed and up-to-date.
Precision on why i'm doing this: i just installed Rails 5 on my computer and when i run the server, i have this error:
rbenv: version `ruby-2.5.0' is not installed (set by /Users/JUSTINE/desktop/code/test_five/.ruby-version)
When i run ruby -v, the output is ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17] .
Any idea?
Clone both rbenv and ruby-build using the below links
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
Now you'll have the ruby-build directory inside plugins.
cd ~/.rbenv
git pull
cd plugins/ruby-build
git pull
After this, you should 2.5.0 when you run rbenv install --list
So, what I'd do is try to see if you have the correct version of macOS command line tools installed. You could run:
xcode-select --install
Or you could start from scratch with:
rm -rf /Library/Developer/CommandLineTools
Then install the command line tools with the code above, or the better way which I found, was going directly to the Apple Developer site and downloading the command line tools package itself and installing that.
Install Command Line tools version 10.13 from here.
This issue also came up for me, but it came up when I started running Mojave. I believe it's the same thing here because I got the same errors.
I removed ALL content from /usr/local/bin folder (including 'brew'). Homebrew isn't working anymore and I seem to be stuck in a limbo. When I try to install it says:
It appears Homebrew is already installed. If your intent is to
reinstall you should do the following before running this installer
again:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
When I run the given uninstall command it says:
Failed to locate Homebrew!
Background
The problem arose when I attempted to remove node.js by following this guide:
https://stackoverflow.com/a/11178106/1736012
To completely uninstall node + npm is to do the following:
go to /usr/local/lib and delete any node and node_modules
go to /usr/local/include and delete any node and node_modules directory
if you installed with brew install node, then run brew uninstall node in your terminal
check your Home directory for any local or lib or
include folders, and delete any node or node_modules from there
go to /usr/local/bin and delete any node executable
Especially 5 was bad! That's what led me to remove everything under /usr/local/bin. So brew doctor won't work (brew isn't recognized anymore). Brew worked fine before this.
What I tried
This does not work either as brew is missing:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"
I tried various scripts like this one for example: https://apple.stackexchange.com/a/85481. And this: https://gist.github.com/SteveBenner/11254428. None of them is working (both assumes that brew command is there)...
What can I do to re install Homebrew so that it works as before??
This should bring back a working brew command:
cd /usr/local/Homebrew
git init
git remote add origin https://github.com/Homebrew/homebrew
git pull origin master
Next I would check the output of brew doctor and see if there are major problems. There is an official uninstalling guide on homebrew's github wiki in case you want to completely uninstall.
Try to move or remove the Homebrew file in the user/local file and then try the regular link from the homebrew homepage to install the brew!
By the way, I did not try moving but I am pretty sure it should work.
Note: While the operation you might have to use the sudo
I faced the same issue, the following link really worked for me
https://github.com/Homebrew/brew/issues/10368
especially comment from MrBenFTW commented on Feb 2021
I have been struggling with this for a few hours. I am on a Mac using Yosemite. I had homebrew installed, and was using git just fine. I tried doing $git add -i and I got this error:
Can't locate Git.pm in #INC (#INC contains:
So I followed the instructions here:
Can't locate Git.pm in #INC
$brew uninstall git worked fine, but after I tried to $brew install git I've been stuck in a terrible cycle.
% brew install git
Error: git-git already installed
To install this version, first `brew unlink git'
% brew unlink git
Error: No such keg: /usr/local/Cellar/git
% brew link git
Error: No such keg: /usr/local/Cellar/git
% git --version
git version 1.9.3 (Apple Git-50)
% brew upgrade git
==> Upgrading 1 outdated package, with result:
git 2.2.2
Error: /usr/local/Library/LinkedKegs/git is not a valid keg
% brew install git
Error: git-git already installed
To install this version, first `brew unlink git'
%
I just want to get homebrew & git back to normal and linked to the correct repo again. I'm really rough around the edges at this stuff, so any help would be greatly appreciated!
Give another go at force removing the brewed version of git
brew uninstall --force git
Then cleanup any older versions and clear the brew cache
brew cleanup -s git
Remove any dead symlinks
brew cleanup --prune-prefix
Then try reinstalling git
brew install git
If that doesn't work, I'd remove that installation of Homebrew altogether and reinstall it. If you haven't placed anything else in your brew --prefix directory (/usr/local by default), you can simply rm -rf $(brew --prefix). Otherwise the Homebrew wiki recommends using a script at https://gist.github.com/mxcl/1173223#file-uninstall_homebrew-sh
Had a similar issue while installing "Lua" in OS X using homebrew. I guess it could be useful for other users facing similar issue in homebrew.
On running the command:
$ brew install lua
The command returned an error:
Error: /usr/local/opt/lua is not a valid keg
(in general the error can be of /usr/local/opt/ is not a valid keg
FIXED it by deleting the file/directory it is referring to, i.e., deleting the "/usr/local/opt/lua" file.
root-user # rm -rf /usr/local/opt/lua
And then running the brew install command returned success.
Os X Mojave 10.14 has:
Error: The Command Line Tools header package must be installed on
Mojave.
Solution. Go to
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
location and install the package manually. And brew will start working and we can run:
brew uninstall --force git
brew cleanup -s git
brew cleanup --prune-prefix
brew install git
A friend of mine need to clone a git repo, but on his machine is xcode not installed and when he tries to use git his Macbook says
The command git requires the command line developer tools, do you want to install them?
The picture is in German.
So is it possible to use git on OS X without Xcode?
Yes. Instead of using the built-in git command:
Install Homebrew if you haven't already:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Run brew update && brew install git
Restart Terminal (or close the current tab and open a new one)
Before you do this:
$ git --version
git version 1.9.3 (Apple Git-50)
After you do this:
$ git --version
git version 2.2.1
How about using SourceTree.app?
http://www.sourcetreeapp.com/
SourceTree.app has also git binary.
$ SourceTree.app/Contents/Resources/git_local/bin/git --version
git version 2.2.1
EDIT
he has github for mac installed and git, but it shows this message anyway :(
I guess he didn't set PATH env, so that git was /usr/bin/git. He should use /Applications/GitHub.app/Contents/Resources/git/bin/git instead of git, or set PATH env.
I installed rbenv via Homebrew on an OS X 10.9.3 MacBook Pro:
brew update
brew upgrade rbenv ruby-build
According to rbenv install --list on my laptop Ruby 2.1.0-dev is the latest.
Both rbenv and ruby-build are generally installed from Github by cloning; That's how the authors recommend we install it.
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
If you didn't do it that way I'd recommend that method. Then, you can simply do:
cd ~/.rbenv
git pull
cd plugins/ruby-build
git pull
If you have several plugins use:
cd plugins
for i in *
do
cd $i
git pull
cd -
done
I update every couple weeks just to pull in the latest fixes/changes.
I faced the same issue. I got the latest by running the following command:
brew upgrade --HEAD ruby-build
I had this issue on OS X 10.8.5 (so don't think OS related). I had tried updating rbenv & ruby-build via brew. 2.1.0-dev was still latest build available.
I had to force uninstall and re-install ruby-build via brew to fix the issue.
brew uninstall ruby-build --force
brew install ruby-build
I had the same issue. Even after running
brew upgrade rbenv ruby-build
I still didn't get ruby-2.1.2 on the available list.
Following how to update list of available ruby versions on linux, I updated ruby-build through the following commands
cd ~/.rbenv/plugins/ruby-build
git pull
(I'm using OS X 10.9.4 MacBook Air)
This happened to me today. "rbenv install -l' displays outdated list while "ruby-build --definitions" returns the correct list. The problem is fixed by executing following command:
rm -Rf ~/.rbenv/plugins/ruby-build
It seems there is an outdated version of ruby-build under ~/.rbenv/plugins. Not sure when it got generated.
This link
gives a good explanation of the two available options.
If you installed rbenv from the git repository:
$ cd ~/.rbenv/plugins/ruby-build
$ git pull
If you used Homebrew on OSX to install rbenv:
$ brew update
$ brew upgrade ruby-build
(Also running brew doctor might give you the exact solution.)
And if you have permission denied errors, this is my addition:
$ sudo chown -R $USER /usr/local; brew update
$ sudo chown -R $USER /usr/local; brew upgrade ruby-build
Then you'll be able to install the recent versions.
$ rbenv install --list
$ rbenv install 2.1.2
The selected answer will work fine, but the issue may have simply been caused by homebrew not having an up-to-date formula for ruby-build at the time. As of this posting, the appropriate ruby-build formula has been put into the latest version of homebrew. So running:
$ brew update
should get you version needed to get the latest ruby. Then, running rbenv install --list again should list 2.1.2 (and others).
So if anyone sees this later on, hopefully you can avoid having to maintain the individual repositories if you'd rather use homebrew for package management.
I've just updated ruby-build and ruby-install to latest versions and both have the latest ruby 2.1.2
Probably rbenv doing something nasty.
Following all the above, on OSX 10.11 it still wouldn't list the latest versions. What I did below worked for me- I removed the dir, re-installed from brew then I had to link in brew like this:
$ brew uninstall ruby-build --force
$ rm -Rf ~/.rbenv/plugins/ruby-build
and then
$ brew install ruby-build
$ brew link --overwrite ruby-build
and then I saw the most recent versions to build.
cd /home/[user]/.rbenv/plugins/ruby-build && git pull && cd -
Don't forget to replace [user] with your user