Programming

OS X“El Capitan”에 gem을 설치할 수 없습니다

procodes 2020. 5. 17. 19:43
반응형

OS X“El Capitan”에 gem을 설치할 수 없습니다


fakes3El Capitan Beta 5 에서 gem 을 설치하고 실행할 수 없습니다 .

나는 시도했다 :

sudo gem install fakes3
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/fakes3

그런 다음 cocoapods 방식으로 시도했습니다. 그것은 cocoapods에는 효과가 있지만 fakes3에는 효과가 없습니다.

mkdir -p $HOME/Software/ruby
export GEM_HOME=$HOME/Software/ruby
gem install cocoapods
[...]
1 gem installed
gem install fakes3
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

면책 조항 : @theTinMan 및 기타 Ruby 개발자는 sudo보석을 설치할 때 사용하지 말고 RVM 과 같은 것을 지적합니다 . 루비 개발을 할 때 그것은 사실입니다. 계속해서 사용하십시오.

그러나 우리 중 많은 사람들이 그냥 일어나는 일부 바이너리가 보석으로 배포 할 (예를 들어 fakes3, cocoapods, xcpretty...). 나는 별도의 루비를 관리하는 것을 귀찮게하고 싶지 않습니다. 더 빠른 옵션은 다음과 같습니다.

옵션 1 : sudo를 계속 사용

사용은 sudo이러한 도구는 전 세계적으로 설치하려면 아마 괜찮습니다.

문제는 이러한 바이너리로 설치되어 있는지입니다 /usr/bin- 출입 금지 엘 카피 탄 이후가. 그러나 /usr/local/bin대신 설치할 수 있습니다 . 그것은 Homebrew 가 물건을 설치하는 이므로 이미 존재할 것입니다 .

sudo gem install fakes3 -n/usr/local/bin

보석이 설치되며 /usr/local/bin시스템의 모든 사용자가 PATH 에 있으면 사용할 수 있습니다 .

옵션 2 : 홈 디렉토리에 설치 (sudo없이)

다음은 gem을 설치 ~/.gem하고 바이너리를 넣을 것입니다 ~/bin(다음에 추가해야합니다 PATH).

gem install fakes3 --user-install -n~/bin

기본값으로 설정

어느 쪽이든, 당신은 ~/.gemrc당신이 그들을 기억하지 않아도 이러한 매개 변수를 추가 할 수 있습니다 :

gem: -n/usr/local/bin

echo "gem: -n/usr/local/bin" >> ~/.gemrc

또는

gem: --user-install -n~/bin

echo "gem: --user-install -n~/bin" >> ~/.gemrc

( 팁 : 당신은 또한에 던질 수있는 --no-document루비 개발자 문서를 생성 건너 뛸 수 있습니다.)


필자의 경우 Brew를 사용하여 Ruby를 다시 설치해야했습니다 . 보석을 다시 설치할 수 있기 때문에 문제가 해결 된 것 같습니다.

brew install ruby

그런 다음 그래픽으로 또는 터미널을 다시 시작하여 로그 아웃했다가 다시 로그인해야합니다.


OS X "El Capitan"의 새로운 보안 기능 때문입니다. --user-installsudo를 사용 하는 대신 추가하십시오 :

$ gem install *** --user-install

예를 들어, fake3을 설치하려면 다음을 사용하십시오.

$ gem install fake3 --user-install

sudo gem install -n /usr/local/bin cocoapods

이 시도. 확실히 작동합니다.


Xcode를 최신 버전 (v7.0.1)으로 업데이트해야하며 모든 것이 정상적으로 작동합니다.

최신 Xcode를 설치 한 후에도 여전히 작동하지 않으면 다음과 같이 gem을 설치하십시오.

sudo gem install -n /usr/local/bin GEM_NAME_HERE

예를 들면 다음과 같습니다.

sudo gem install -n /usr/local/bin fakes3
sudo gem install -n /usr/local/bin compass
sudo gem install -n /usr/local/bin susy

Looks like when upgrading to OS X El Capitain, the /usr/local directory is modified in multiple ways :

  1. user permissions are reset (this is also a problem for people using Homebrew)
  2. binaries and symlinks might have been deleted or altered

[Edit] There's also a preliminary thing to do : upgrade Xcode...

Solution for #1 :

$ sudo chown -R $(whoami):admin /usr/local

This will fix permissions on the /usr/local directory which will then help both gem install and brew install|link|... commands working properly.

Solution to #2 :

Ruby based issues

Make sure you have fixed the permissions of the /usr/local directory (see #1 above)

First try to reinstall your gem using :

sudo gem install <gemname>

Note that it will install the latest version of the specified gem.

If you don't want to face backward-compatibility issues, I suggest that you first determine which version of which gem you want to get and then reinstall it with the -v version. See an exemple below to make sure that the system won't get a new version of capistrano.

$ gem list | grep capistrano
capistrano (3.4.0, 3.2.1, 2.14.2)
$ sudo gem install capistrano -v 3.4.0

Brew based issues

Update brew and upgrade your formulas

$ brew update
$ brew upgrade

You might also need to re-link some of them manually

$ brew link <formula>

As it have been said, the issue comes from a security function of Mac OSX since "El Capitan".

Using the default system Ruby, the install process happens in the /Library/Ruby/Gems/2.0.0 directory which is not available to the user and gives the error.

You can have a look to your Ruby environments parameters with the command

$ gem env

There is an INSTALLATION DIRECTORY and a USER INSTALLATION DIRECTORY. To use the user installation directory instead of the default installation directory, you can use --user-install parameter instead as using sudo which is never a recommanded way of doing.

$ gem install myGemName --user-install

There should not be any rights issue anymore in the process. The gems are then installed in the user directory : ~/.gem/Ruby/2.0.0/bin

But to make the installed gems available, this directory should be available in your path. According to the Ruby’s faq, you can add the following line to your ~/.bash_profile or ~/.bashrc

if which ruby >/dev/null && which gem >/dev/null; then
    PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi

Then close and reload your terminal or reload your .bash_profile or .bashrc (. ~/.bash_profile)


This is the solution that I have used:

Note: this fix is for compass as I wrote it on another SO question, but I have used the same process to restore functionality to all terminal processes, obviously the gems you are installing are different, but the process is the same.

I had the same issue. It is due to Apple implementing System Integrity Protection (SIP). You have to first disable that...

Reboot in recovery mode:

Reboot and hold Command + R until you see the apple logo.

Once booted select Utilities > Terminal from top bar.

type: csrutil disable

then type: reboot

Once rebooted

Open terminal back up and enter the commands:

sudo gem uninstall bundler

sudo gem install bundler

sudo gem install compass

sudo gem install sass

sudo gem update --system

The the individual gems that failed need to be fixed, so for each do the following:

On my machine this was the first dependency not working so I listed it:

sudo gem pristine ffi --version 1.9.3

Proceed through the list of gems that need to be repaired. In all you are looking at about 10 minutes to fix it, but you will have terminal commands for compass working.

Screenshot


If the gem you are trying to install requires xml libraries, then try this:

sudo gem install -n /usr/local/bin  <gem_name> -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/

Specifically, I ran into a problem while installing the nokogiri gem v 1.6.8 on OS X El Capitan

and this finally worked for me:

sudo gem install -n /usr/local/bin  nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/

To make sure you have libxml2 and libxslt installed, you can do:

brew install libxml2 libxslt
brew install libiconv

and then check to make sure you have xcode command line tools installed:

xcode-select --install 

should return this error:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Reinstalling RVM worked for me, but I had to reinstall all of my gems afterward:

rvm implode
\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm reload

I ran across the same issue after installing El Capitan, I tried to install sass and compass into a symfony project, the following command returned the following error:

$ sudo gem install compass

ERROR: Error installing compass: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb 

checking for ffi.h... /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)

So I then tried to install sass with: $ sudo gem install sass

Got the same error message, after some googling I managed to install sass using the following command:

$ sudo gem install -n /usr/local/bin sass

The above worked for me with installing sass but did not work for installing compass. I read that someone somewhere had opened an instance of xcode then closed it again, then successfully ran the same command after which worked for them. I attempted to open xcode but was prompted with a message saying that the version of xcode installed was not compatible with El Capitan. So I then updated xcode from the app store, re-ran the following command which this time ran successfully:

$ sudo gem install -n /usr/local/bin compass

I was then able to run $ compass init

I now have all my gems working and can proceed to build some lovely sass stuff :)


I had to rm -rf ./vendor then run bundle install again.


I don't like to install stuff with sudo. once you start with sudo you can't stop..

try giving permissions to the Gems directory.

sudo chown -R $(whoami) /Library/Ruby/Gems/2.0.0

sudo chown -R $(whoami):admin /usr/local

That will give permissions back (Homebrew installs ruby there)

참고URL : https://stackoverflow.com/questions/31972968/cant-install-gems-on-os-x-el-capitan

반응형