简体   繁体   中英

Rails does not work on Lion

I changed my Mac OSX version to Lion. However I cannot create a Rails3 app.

I use rvm 1.9.2 and i choose ruby 1.9.2-p290 to create Rails 3 app.

Everything seems okey. When I start to create a new app

rails new new_my_app

I see this errors,

Installing json (1.6.6) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/ender/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
creating Makefile

make
sh: make: command not found


Gem files will remain installed in /Users/ender/.rvm/gems/ruby-1.9.2-p290/gems/json-1.6.6 for inspection.
Results logged to /Users/ender/.rvm/gems/ruby-1.9.2-p290/gems/json-1.6.6/ext/json/ext/generator/gem_make.out
An error occured while installing json (1.6.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.6.6'` succeeds before bundling.

When I try

gem install json -v '1.6.6'

I face this errors

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

        /Users/ender/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
creating Makefile

make
sh: make: command not found


Gem files will remain installed in /Users/ender/.rvm/gems/ruby-1.9.2-p290/gems/json-1.6.6 for inspection.
Results logged to /Users/ender/.rvm/gems/ruby-1.9.2-p290/gems/json-1.6.6/ext/json/ext/generator/gem_make.out

What should I do to fix this problem?

Thanks.

您需要从Xcode 4 for Lion中的首选项安装“命令行工具”。

You need to install osx-gcc-installer

If you migrated ruby from previoys system you need to reinstall ruby and gems:

rvm reinstall 1.9.2
rvm use 1.9.2
rvm gemset pristine

I had this issue and this fixed it for me. I recently migrated from an older system to a new iMac.

I first installed libksba. I'm not sure if it's necessary, but I guess it doesn't hurt. I use homebrew so this is what I did:

brew install libksba

Then, I updated rvm.

rvm get head

After updating, it informed me that I needed to install ruby-1.9.3-p194.

rvm install ruby-1.9.3-p194

That got 1.9.3 installed. I wanted 1.9.2 for some older apps so I then reinstalled that.

rvm reinstall 1.9.2

Finally, I installed the json gem that was causing this issue:

gem install json -v '1.6.6'

Viola! It installed correctly. The last thing I did was to run bundle, but it was complaining about not finding this:

Could not find multi_json-1.3.1 in any of the sources

I removed Gemfile.lock and re-ran bundle.

rm Gemfile.lock
bundle

And everything works now!

Finally I won it. Maybe it could be the short or easy way. You know. Firstly, I updated the RVM but before it, i installed Xcode 4 from appstore for Lion. The second step is the reinstall the lastest stabil ruby version and create my gemset. And finally I download the rails 3.2 to the gem set which i set before on ruby the lastest.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM