Tried to install a gem on Mountain Lion and make couldn\'t find gcc-4.2:
kamil$ gem install posix-spawn -v \'0.3.6\'
Building native extensions. This could
If you have Xcode installed, gcc should be available. Check where it is with:
kamil$ which gcc
/usr/bin/gcc
Then make a user-land symbolic link from gcc-4.2 to plain gcc:
kamil$ sudo ln -s ~/bin/gcc /usr/bin/gcc-4.2
(Ensure the user-land bind folder is in your path via export PATH=...:$HOME/bin
in your .bash_profile
or .zshrc
.)
Gem installed fine afterwards.
As @Artur Bodera mentioned modern OSX will refuse to let you create the symlink in the systems /bin folder.
To avoid this simply create the symlink to your users bin folder
ln -s ~/bin/gcc /usr/bin/gcc-4.2
Don't forget to add the bin folder to your .zshrc or .bash_profile - e.g.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin
I had a similar issue while installing a python pip package (building a wheel failed). I got the similar message:
unable to execute '/usr/bin/gcc-4.2': No such file or directory
error: command '/usr/bin/gcc-4.2' failed with exit status 1
Linking /usr/bin/gcc-4.2
to /usr/bin/gcc
was not possible due to Apples System Integrity Protection (SIP), and linking it to /usr/local/bin/gcc-4.2
was not picked up by the wheel building process; it was still trying to use /usr/bin/gcc-4.2
.
I was finally able to solve this by setting the CC
variable in the terminal:
CC=/usr/bin/gcc
# Install your packages
pip install -r requirements.txt
PS : note that disabling SIP doesn't work, even with SIP disabled I wasn't able to create the /usr/bin/gcc-4.2
link.
Install simply apple-gcc42 with brew. It generate gcc-4.2 .
brew install apple-gcc42
So we do not need symlinks, which apple update may remove.
Homebrew