ruby-on-rails – 为什么“gem install rails”失败?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 为什么“gem install rails”失败?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
作为背景,这里是我的环境:
vishal@dishDell:~$gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.9.1
     - /home/vishal/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

这是当我尝试运行gem安装rails时会发生什么.

vishal@dishDell:~$sudo gem install rails
[sudo] password for vishal: 
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
    from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from extconf.rb:1:in `<main>'


Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/json-1.7.3 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/json-1.7.3/ext/json/ext/parser/gem_make.out

我使用apt-get安装了Ruby 1.9.3,并且在rubygems.org中从tarball安装了RubyGems.我应该怎么做才能使这个工作?

解决方法

如其他 Stackoverflow question中所指出的那样,检查你是否有ruby-1.9-dev或ruby-1.9.3-dev软件包.如果缺少安装,然后尝试安装rails.

另外,请看一下RVM在同一时间安装和管理多个ruby版本.

猜你在找的Ruby相关文章