简体   繁体   English

Rails不适用于Lion

[英]Rails does not work on Lion

I changed my Mac OSX version to Lion. 我将Mac OSX版本更改为Lion。 However I cannot create a Rails3 app. 但是我无法创建Rails3应用程序。

I use rvm 1.9.2 and i choose ruby 1.9.2-p290 to create Rails 3 app. 我使用rvm 1.9.2并选择ruby 1.9.2-p290来创建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 您需要安装osx-gcc-installer

If you migrated ruby from previoys system you need to reinstall ruby and gems: 如果您从previoys系统迁移ruby,则需要重新安装ruby和gem:

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. 我最近从旧系统迁移到新的iMac。

I first installed libksba. 我首先安装了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。

rvm get head

After updating, it informed me that I needed to install ruby-1.9.3-p194. 更新后,它通知我需要安装ruby-1.9.3-p194。

rvm install ruby-1.9.3-p194

That got 1.9.3 installed. 安装了1.9.3。 I wanted 1.9.2 for some older apps so I then reinstalled that. 我想要一些旧的应用程序的1.9.2,所以我然后重新安装。

rvm reinstall 1.9.2

Finally, I installed the json gem that was causing this issue: 最后,我安装了导致此问题的json gem:

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: 我做的最后一件事是运行bundle,但它抱怨没有找到这个:

Could not find multi_json-1.3.1 in any of the sources

I removed Gemfile.lock and re-ran bundle. 我删除了Gemfile.lock并重新运行了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. 首先,我更新了RVM,但在此之前,我从appstore为Lion安装了Xcode 4。 The second step is the reinstall the lastest stabil ruby version and create my gemset. 第二步是重新安装最新的稳定ruby版本并创建我的gemset。 And finally I download the rails 3.2 to the gem set which i set before on ruby the lastest. 最后我将rails 3.2下载到我之前在ruby上设置的gem集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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