![](/img/trans.png)
[英]Why I obtain this error message installing the Ruby bundler gem “ERROR: Failed to build gem native extension”?
[英]ERROR: Failed to build gem native extension message (Linux) installing rubygems
我正在通過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.4Your user account isn't allowed to install to the system Rubygems. You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to Rubygems using sudo.
Password:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/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
require' from extconf.rb:1:in `'Gem files will remain installed in /tmp/bundler20140908-2757-18q0kfn/json-1.8.1/gems/json-1.8.1 for inspection. Results logged to /tmp/bundler20140908-2757-18q0kfn/json-1.8.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out An error occurred while installing json (1.8.1), and Bundler cannot continue. Make sure that
gem install json -v '1.8.1'
succeeds before bundling.ben@ben-X551CA ~/first_rails_project/bens_first_app $ gem install json -v '1.8.1' ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions into the /var/lib/gems/1.9.1 directory. ben@ben-X551CA ~/first_rails_project/bens_first_app $ sudo gem install json -v '1.8.1' Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension.
/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
require'from 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 $
所以運行這個對我有用:
sudo apt-get install ruby1.9.1-dev
假設需要-dev
包?
如果@BenLawton的答案不起作用試試這個(在Ubuntu 16.04上為我工作):
sudo apt-get install ruby-full
https://www.ruby-lang.org/en/documentation/installation/#apt
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.