13

作为背景,这是我的环境:

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 install 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

我使用 安装了 Ruby 1.9.3 apt-get,并从 ruby​​gems.org 的 tarball 安装了 RubyGems。我应该怎么做才能让它工作?

4

2 回答 2

18

这适用于 Ubuntu 12.10:

sudo apt-get install ruby
sudo apt-get install ruby-dev
sudo apt-get install rubygems
sudo gem install rails
于 2012-10-27T05:45:24.617 回答
9

正如另一个Stackoverflow 问题中所指出的,检查您是否有 ruby​​-1.9-dev 或 ruby​​-1.9.3-dev 包。如果丢失,请安装它,然后尝试安装 rails。

此外,请查看RVM以同时安装和管理多个 ruby​​ 版本。

于 2012-07-14T07:12:46.343 回答