忽略bcrypt-3.1.11,因为它的扩展未构建。尝试:gem pristine bcrypt --version 3.1.11

时间:2016-09-21 20:36:08

标签: ruby-on-rails ruby rubygems

在MacOS Sierra [2016年9月22日]

通过 rvm 将ruby升级到5.3.1,然后选中 ruby​​ -v

ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

然后我尝试使用gem

安装rails
gem install rails -v 5.0.0.1

显示错误

  Ignoring bcrypt-3.1.11 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.11
Ignoring binding_of_caller-0.7.2 because its extensions are not built.  Try: gem pristine binding_of_caller --version 0.7.2
Ignoring byebug-9.0.5 because its extensions are not built.  Try: gem pristine byebug --version 9.0.5
Ignoring byebug-8.2.2 because its extensions are not built.  Try: gem pristine byebug --version 8.2.2
Ignoring capybara-webkit-1.11.1 because its extensions are not built.  Try: gem pristine capybara-webkit --version 1.11.1
Ignoring debug_inspector-0.0.2 because its extensions are not built.  Try: gem pristine debug_inspector --version 0.0.2
/Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': incompatible library version - /Users/chutipongroobklom/.rvm/gems/ruby-2.3.1/gems/io-console-0.4.6/lib/io/console.bundle (fatal)
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/user_interaction.rb:9:in `<top (required)>'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/command.rb:10:in `<top (required)>'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/command_manager.rb:8:in `<top (required)>'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/gem_runner.rb:9:in `<top (required)>'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/chutipongroobklom/.rvm/rubies/ruby-2.3.1/bin/gem:9:in `<main>'
  1. 发生了什么事?
  2. 根本原因是什么?
  3. 接下来我该怎么办?
  4. 以后如何防止此错误?
  5. 提前谢谢

4 个答案:

答案 0 :(得分:2)

gem pristine -a
bundle install
bundle update

为我解决了这个问题

由于先前的尝试,我也将这些行注释掉了,不确定是否有帮助。

# gem 'spring'
# gem 'spring-watcher-listen', '~> 2.0.0'

答案 1 :(得分:1)

可能在更新期间您还安装了新的XCode,它包含构建扩展所需的库。但是,在您接受XCode许可证并安装新组件之前,它将无法运行。 XCode会在第一次运行时为您完成。

因此,首先运行XCode,接受许可证,安装缺少的组件(XCode应自动询问您是否要安装它们)。

可能需要重新安装ruby。 (在此描述:https://stackoverflow.com/a/16775469/2074939

重启控制台。

如果这是您第一次在系统上安装Ruby和Ruby on Rail,我建议您阅读: https://gorails.com/setup/osx/10.12-sierra

答案 2 :(得分:1)

我只是花了一天时间试图解决类似的问题。问题可能来自您当前红宝石版本或较旧版本的.gem ~/.gem/ruby文件夹中的冲突。要解决此问题,您可以手动删除这些文件夹并通过以下方式重新安装rails gem: rm -rf ~/.gem/ruby/<ruby_version> gem install bundler bundle install

下次使用该ruby版本时,将重新生成该文件夹。如果您正在使用ruby软件包管理器(即Chruby),您应该能够在应用程序中切换ruby版本并查看哪些Ruby版本会出现警告,并且只能通过命令删除该版本的gem上方。

我发现其他解决方案建议在所有现有的ruby版本上运行gem pristine -a,但这似乎并不能解决我的问题。

答案 3 :(得分:1)

重新安装您当前的宝石,问题将得到解决。

我用的是

rvm reinstall ruby-2.2.5