在我的工作电脑和家用电脑上,我最近使用Ruby -install将Ruby升级到2.3.1。我使用chruby作为Ruby切换器。

我开始在我的终端上看到这样的警告:

Ignoring bcrypt-3.1.11 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.11
Ignoring bcrypt-3.1.10 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.10
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-5.0.0 because its extensions are not built.  Try: gem pristine byebug --version 5.0.0
Ignoring concurrent-ruby-ext-1.0.2 because its extensions are not built.  Try: gem pristine concurrent-ruby-ext --version 1.0.2
Ignoring debug_inspector-0.0.2 because its extensions are not built.  Try: gem pristine debug_inspector --version 0.0.2

在我的工作电脑上,清单要长得多,但很容易解决。当我尝试建议的gem原始gem时,它告诉我找不到宝石,所以我运行gem安装gem,这就解决了问题。

在家里,一切都不正常。

我从常识和其他Stack问题中尝试过的事情:

gem pristine GEM gem pristine --all uninstalling and reinstalling the gem gem update gem update --system bundle update uninstalling and reinstalling bundler uninstalling and reinstalling rails (Though, it's not a Rails specific problem.) deleting ~/.bundle/ opening XCode and letting it install some extensions (It did need to do it, but it didn't fix anything.) running brew doctor and solving all the minor issues, then brew update and brew upgrade gem install curb (I can't imagine what this gem has to do with this issue, but two different people listed it as the last step of their fix to the same warning.)


当前回答

我在Terminal中执行了这些命令,并为我工作:

/usr/bin/ruby -e "$(curl - ssl https://raw.githubusercontent.com/Homebrew/install/master/install)" Brew安装ruby,可能需要sudo (sudo Brew install ruby)。 echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile . bat 源~ / . bash_profile Sudo宝石原始——全部

其他回答

这里的大多数评论都是正确的。这个问题经常发生在Ruby版本升级之后。我回顾了gem命令代码,下面是它的要点。

扩展被编译到gems主目录的gems/gem/ext子目录中。例如,在我的Cygwin安装上(在Raspbian下也类似),BigDecimal扩展被编译成 /usr/share/gems/gems/bigdecimal-1.3.5 / ext / bigdecimal / bigdecimal.so。

然而,这并不是执行扩展时引用的地方——而是从那里引用的 /usr/lib/gems/ruby/ver/gem.同样使用BigDecimal,从执行时加载扩展文件 /usr/lib/gems/ruby/2.3.0/bigdecimal-1.3.5 / bigdecimal.so

这里是关键:在同一个目录中,有一个空的标记文件 /usr/lib/gems/ruby/2.3.0/bigdecimal-1.3.5 / gem.build_complete

当gem命令启动时,它会引用gems/specifications目录以获得已安装gems的列表以及关于它们是否具有扩展的信息。如果一个gem确实有扩展,gem(在其他健全性检查中)会查找标记文件gem.build_complete。如果没有找到,它会发出错误消息“忽略gem,因为它的扩展没有构建”。

任何重新构建所有扩展的操作都将修复这个问题。或者,完全hack,如果你在匆忙和勇敢,你可以尝试复制/usr/lib/gems/ruby/oldver的所有内容到/usr/lib/gems/ruby/newver。

cd /usr/lib/gems/ruby
cp -nv 2.3.0/* 2.6 

我也有同样的问题,我用的是rbenv。由于某种原因,我的全局rbenv设置丢失了。为了解决这个问题,我将全局版本设置为我的rbenv版本之一…例如:

Rbenv global 2.5.1

我有这个问题,但只有当我启动tmux会话使用tmuxinator。

原来这是因为我使用tmuxinator从brew而不是安装它使用gem安装。也许同时使用chruby也导致了这个问题。

p/s:我也从~/中删除了未使用的ruby。宝石/红宝石,但我怀疑这是这个问题为我解决的原因。

TL;DR - Ruby宝石不喜欢红宝石从符号链接中运行或从它们构建的地方移动(因为嵌入式shebangs)

如果Ruby目录被调用,或者环境变量指向一个符号链接的目录,或者被复制或重命名,就可能出现此消息。我使用chruby和符号链接/opt/rubies/ -> /usr/local/ Ruby /,但Ruby的动态库查找逻辑不能很好地发挥这一点。

在我的案例中,解决方案是将符号链接替换为/opt/ Ruby /中的实际红宝石,并运行gem质朴——所有这些都在每个Ruby中。对于其他使用RVM或Rbenv的用户,祝您好运,不必从头开始。

这可能不是你的问题,但希望它能有所帮助。

如果你像我一样使用rvm,修复可以很简单:

rvm get stable
rvm reload

如此答案https://apple.stackexchange.com/a/192513所述