Why won't bundler install the json 1.7.4 gem o

2020-07-07 18:09发布

I'm on OS X 10.8 with XCode 4.4, Ruby 1.9.3, and Rails 3.2.

When I clone my rails project from git and run:

bundle install

I get:

Installing json (1.7.4) Errno::EPERM: Operation not permitted - /Users/myuser/.rvm/gems/ruby-1.9.3-p0/gems/json-1.7.4/.gitignore An error occurred while installing json (1.7.4), and Bundler cannot continue. Make sure that gem install json -v '1.7.4' succeeds before bundling.

Then I try:

gem install json -v '1.7.4'

and get:

ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /Users/scalessec/.rvm/gems/ruby-1.9.3-p0/gems/json-1.7.4/.gitignore

Okay. Permissions issue, right? Let's try:

sudo gem install json -v '1.7.4'

No go. Here's what I get:

Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension.

/Users/myuser/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb creating Makefile

make compiling generator.c make: /usr/bin/gcc-4.2: Permission denied make: * [generator.o] Error 1

What the heck?

4条回答
对你真心纯属浪费
2楼-- · 2020-07-07 18:45

I am not sure, but I upgraded to OS X 10.8 2 days ago (from Lion, where my Rails configuration worked fine). And I had the same JSON 1.7.4 issue.

Eventually, I solved the problem by noticing that Xcode's command line tools were NOT installed (but they were on OS X 10.7!). I just reinstalled CLI tools in Xcode and that JSON 1.7.4 issue disappeared.

Also just in case it's helpful, check out this guide: https://thoughtbot.com/blog/the-hitchhikers-guide-to-riding-a-mountain-lion

查看更多
Evening l夕情丶
3楼-- · 2020-07-07 18:50

Thanks to aabulkhairov for his solution.

Here's one for anyone having the same symptom but still running OS X Lion

I was able to updating Xcode to 4.4 from the App Store, then using XCode > Preferences > Downloads to install CLI tools; this resolved the problem. The new XCode is compatible with Lion, and my Rails app is running as expected.

I think I got into this state because the previous version of XCode 4.2.1, installed from the App Store, had displaced my even older version downloaded from developer.apple.com -- that's likely where I lost the CLI tools. Since that time, I apparently never needed to compile a gem with native extensions again.

查看更多
男人必须洒脱
4楼-- · 2020-07-07 18:51

Re-install CLI tools worked for me.

Use the top answer here: How to use/install gcc on Mac OS X 10.8 / Xcode 4.4

查看更多
该账号已被封号
5楼-- · 2020-07-07 18:51

For OS X use:
sudo gem install json --pre for the latest one

Check the version of Ruby you are using. This can be installed easily with ruby 1.9.3. Change the ruby version to 1.9.3 and do

sudo gem install json -v '1.7.4'

查看更多
登录 后发表回答