我正在尝试在Mavericks上运行一个相当旧的Rails应用程序,其中一个要求是:
– Ruby ree-1.8.7-2009.10
– Rails 3.0.0
– libxml-ruby 1.1.4(这是与其他宝石兼容的最新版本.
– Ruby ree-1.8.7-2009.10
– Rails 3.0.0
– libxml-ruby 1.1.4(这是与其他宝石兼容的最新版本.
我安装了最新的libxml2包.它的版本来自Homebrew(2.9.1).
要安装此gem,我使用以下命令:
$CC=gcc-4.2 gem install libxml-ruby -v '1.1.4'
输出建议成功:
Building native extensions. This could take a while... Successfully installed libxml-ruby-1.1.4 1 gem installed
虽然我尝试运行一些rake任务,即创建数据库
捆绑exec rake db:create
我收到以下错误:
$bundle exec rake db:create [ree-1.8.7-2009.10@mygemset] rake aborted! dlsym(0x7ffa2d83bbe0,Init_libxml_ruby): symbol not found - /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/libxml-ruby-1.1.4/lib/libxml_ruby.bundle /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/libxml-ruby-1.1.4/lib/libxml.rb:9 /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require' /Users/myuser/Developer/my-project/vendor/private_gems/restful_authentication-1.4.9/lib/sso/sso.rb:3 /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in `new_constants_in' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in `load_dependency' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@mygemset/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `require' /Users/myuser/Developer/my-project/vendor/private_gems/restful_authentication-1.4.9/lib/restful_sso_authentication.rb:2 /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require' /Users/myuser/.rvm/gems/ree-1.8.7-2009.10@global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require' /Users/myuser/Developer/my-project/config/application.rb:5 /Users/myuser/Developer/my-project/Rakefile:6:in `require' /Users/myuser/Developer/my-project/Rakefile:6 (See full trace by running task with --trace)
我尝试了很多可以在互联网上找到的方法(最相关的例子涉及安装Nokogiri的问题和列出的类似错误),但没有一种方法有效.
解决方法
这是我在很长时间内在各种Mac OS上安装Rubies的方法.对我来说,任何图书馆或宝石都没有任何问题.例如,更复杂的Nokogiri宝石构建和工作就像一个魅力.
检查XCode版本
xcodebuild -version xcode-select --install
按照文档安装Homebrew
安装先决条件
brew doctor; # Just do what it wants! brew update; brew upgrade; # Watch out! for existing bottles brew install libtool libxml2 libxslt openssl sqlite libyaml; brew install autoconf automake apple-gcc42; brew cleanup; # Watch out! for existing bottles brew tap homebrew/dupes; # Watch out! for existing bottles
安装RVM
curl -L https://get.rvm.io | bash -s stable # Latest stable rvm get latest rvm reload # :) rvm autolibs enable rvm requirements
安装Ruby
rvm install 2.1 --disable-binary