错误:无法构建安装rubygems的gem本机扩展消息(Linux)

Ben*_*ton 2 gem json ruby-on-rails linux-mint

我正在通过rails教程atm.(我是初学者,所以请耐心等待.)

正如您在下面看到的,当我尝试使用'bundle install'安装rubygems时,我收到错误消息,说我需要确保'gem install json -v'1.8.1'成功再次尝试之前.

但是当我尝试和sudo gem install json -v'1.8.1'时,我得到了


.

如果我问一个愚蠢的问题,或者我遗漏了任何必要的信息,请告诉我.我是新手 - CodeAcademy&RailsForZombies是我所知的范围.

ben@ben-X551CA ~/first_rails_project/bens_first_app $ bundle install
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.41
Using activesupport 4.0.8
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.0.8
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.0.8
Using activemodel 4.0.8
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using activerecord 4.0.8
Using bundler 1.7.2
Using coffee-script-source 1.8.0
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.0.8
Using coffee-rails 4.0.1
Using hike 1.2.3
Using jbuilder 1.0.2
Using jquery-rails 3.0.4

Your user account isn't allowed to install to the system Rubygems. You can cancel this installation and run:

bundle install --path vendor/bundle
Run Code Online (Sandbox Code Playgroud)

将gem安装到./vendor/bundle/,或者您可以输入密码并使用sudo将捆绑的gem安装到Rubygems.

密码:

Gem :: Installer :: ExtensionBuildError:错误:无法构建gem原生扩展.

    /usr/bin/ruby1.9.1 extconf.rb 
Run Code Online (Sandbox Code Playgroud)

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- mkmf (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in要求'来自extconf.rb:1:in`'

Gem文件将保留在/tmp/bundler20140908-2757-18q0kfn/json-1.8.1/gems/json-1.8.1中进行检查.结果记录到/tmp/bundler20140908-2757-18q0kfn/json-1.8.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out安装json(1.8.1)时发生错误, Bundler无法继续.gem install json -v '1.8.1'在捆绑之前确保成功.

ben @ ben-X551CA~/first_rails_project/bens_first_app $ gem install json -v'1.8.1'ERROR:执行gem时...(Gem :: FilePermissionError)你没有写入/ var/lib/gems的权限/1.9.1目录.ben @ ben-X551CA~/first_rails_project/bens_first_app $ sudo gem install json -v'1.8.1'构建原生扩展.这可能需要一段时间...错误:安装json时出错:错误:无法构建gem原生扩展.

/usr/bin/ruby1.9.1 extconf.rb

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- mkmf (LoadError) from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in要求'来自extconf.rb:1:in`'

Gem文件将保留在/var/lib/gems/1.9.1/gems/json-1.8.1中以供检查.结果记录到/var/lib/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out ben @ ben-X551CA~/first_rails_project/bens_first_app $

Ben*_*ton 7

所以运行这个对我有用:

sudo apt-get install ruby1.9.1-dev
Run Code Online (Sandbox Code Playgroud)

假设-dev需要包裹?