Ruby gem安装错误

时间:2014-02-05 08:13:12

标签: ruby-on-rails ruby json ruby-on-rails-3 gem

这是一个错误摘录:

Using jbuilder (1.5.3) Installing jquery-rails (3.1.0) Installing json (1.8.1) Gem::Installer::ExtensionBuildError: ERROR:
Failed to build gem native extension .

    c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe: No such file or directory
-- extconf.r b (LoadError)

Gem files will remain installed in
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9 .1/gems/json-1.8.1 for
inspection. Results logged to
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.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.

输入gem install json -v返回:

'1.8.1' Temporarily enhancing PATH to include DevKit... Building
native extensions.  This could take a while... ERROR:  Error
installing json:
        ERROR: Failed to build gem native extension.

        c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe: No such file or directory
-- extconf.r b (LoadError)


Gem files will remain installed in
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9 .1/gems/json-1.8.1 for
inspection. Results logged to
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/json-1.8.
1/ext/json/ext/generator/gem_make.out

输入bundle install返回:

Bundler::GemfileNotFound

输入cd qwerty返回:

pmakamgovind@CSCINDAE751352 ~/Desktop/ruby/qwerty $ rails s
←[31mCould not find gem 'rails (= 4.0.2) x86-mingw32' in the gems
available on t his machine.←[0m ←[33mRun `bundle install` to install
missing gems.←[0m

2 个答案:

答案 0 :(得分:1)

尝试在Gemfile上添加以下行: gem 'json', '1.8.1'

然后运行:bundle update以覆盖较新版本的json gem。

答案 1 :(得分:0)

如果您使用的宝石数量不是很大,那么您可以直接提及Github路径并继续使用它。

或者,下载相关特定宝石的Github副本并制作本地副本供您自己使用。这样,您就不必依赖rubygems.org来运行应用程序。

我也遇到了这个问题,后来又知道该网站在那个特定的时间段内出现了问题。

注意 - 您的错误很可能是由于本地计算机上缺少头文件。首先,安装SQL和Ruby头文件,然后再次尝试bundle install