195

在我的工作和家用计算机上,我最近将 Ruby 升级到 2.3.1,使用ruby-install. 我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 pristine GEM时,它告诉我找不到宝石,所以我跑了gem install GEM,解决了它。

在家里,没有任何工作。

我尝试过的事情,来自常识和其他各种堆栈问题:

  • gem pristine GEM
  • gem pristine --all
  • 卸载并重新安装 gem
  • gem update
  • gem update --system
  • bundle update
  • 卸载并重新安装bundler
  • 卸载并重新安装rails(虽然,这不是 Rails 特定的问题。)
  • 删除~/.bundle/
  • 打开XCode并让它安装一些扩展(它确实需要这样做,但它没有解决任何问题。)
  • 运行brew doctor并解决所有小问题,brew update然后brew upgrade
  • gem install curb(我无法想象这个 gem 与这个问题有什么关系,但是两个不同的人将它列为他们修复同一警告的最后一步。)
4

22 回答 22

217

我今天遇到了这个确切的问题 - 甚至没有安装的 gem 收到这样的警告!

...好吧,事实证明,gem安装 - 与我使用 chruby(2.2.3 与 2.3.1)设置的激活的 ruby​​ 不同。

切换到所有不同的红宝石并gem pristine --all在所有红宝石上运行解决了这个问题。

于 2016-10-05T05:59:14.667 回答
33

我遇到了这个问题,并按照上面所有相同的命令进行操作,甚至删除了我以前安装的所有 Ruby 版本。但是,错误仍然存​​在。

事实证明,在~/.gem/ruby/. 删除我不再使用的文件夹后,错误消失了。

于 2016-11-17T00:00:26.607 回答
14

我今天也遇到了这个问题,它很沮丧,因为我无法输入,因为我的整个编辑器都因错误消息而闪烁红色。

我不完全确定究竟是什么原因造成的,但我相信这是因为我们安装了多个 ruby​​ 版本或多个 ruby​​ 版本管理 ,它们相互覆盖,否则会打乱你通往宝石的道路。

gem当您拥有 rbenv 和 rvm 时,该命令也会被覆盖。

通过键入查看您安装了哪些;

which rvm
which rbenv
which chruby

如果安装了其中一个,它将返回一个路径。然后删除它们,确保完全清除所有目录并从全新安装开始。


消除

这是我为rvm 所做的;

rvm implode
gem uninstall rvm
rm -rf ~/.rvm
rm -rf ~/.rvmrc

这是我为rbenv 所做的

先安装https://github.com/meowsus/rbenv-clean,然后

rbenv clean
sudo apt-get remove rbenv
rm -rf ~/.rbenv

重新安装

然后你有一个干净的主目录可以工作。我用How to install Ruby 2.1.4 on Ubuntu 14.04 重新安装了 rbenv 。最后;

rbenv rehash
于 2017-01-12T15:30:27.387 回答
12

我做了上面提到的一切,包括

  • xcode-选择--安装
  • 重新安装红宝石
  • 重新安装所有宝石
  • 宝石原始--全部

但问题对我来说是一样的。我只是重新启动了我的 Mac 作为最后的希望,警告消息消失了。

很奇怪,但是如果有人在尝试 StackOverflow 上的所有内容后遇到此问题,请尝试重新启动您的机器。

于 2016-11-01T14:09:36.187 回答
7

Running gem pristine --all didn't help at first, but then I realized: the script I was running began with the line:

#!/usr/bin/ruby

On my macOS system (Catalina, but I don't think it matters), this points to the Ruby that came with the system, not the one installed by RVM. Running gem pristine --all was fixing up the RVM installation, but my script was calling a different version of Ruby.

The fix for me was to use the env command to call whichever Ruby is specified in the current shell's PATH. Changing the top line of the script to this fixed it:

#!/usr/bin/env ruby

于 2020-01-31T20:58:55.757 回答
6

在这里添加我自己的味道。我使用rbenv的是通过 Homebrew 安装的,并且收到了其中四个“忽略...未构建扩展”的消息。具体来说:

Ignoring bcrypt-3.1.12 because its extensions are not built.  Try: gem pristine bcrypt --version 3.1.12
Ignoring bindex-0.5.0 because its extensions are not built.  Try: gem pristine bindex --version 0.5.0
Ignoring bootsnap-1.3.2 because its extensions are not built.  Try: gem pristine bootsnap --version 1.3.2
Ignoring byebug-10.0.2 because its extensions are not built.  Try: gem pristine byebug --version 10.0.2

我在这个线程中尝试了很多东西,但没有运气。最后在我的情况下,我做到了:

  • brew uninstall rbenv
  • rm -rf ~/.rbenv
  • brew install rbenv

此时我仍然遇到错误,但现在我只有一个 Ruby 版本需要处理:

$ rbenv versions
* system (set by /Users/will/.rbenv/version)

此时我尝试sudo gem pristine --all了,但因系统 Gems 目录的权限而被拒绝。

所以我检查并在每个宝石上运行原始,比如

sudo gem pristine bcrypt --version 3.1.12(ETC)

最后错误消失了。

于 2019-02-28T01:14:28.843 回答
4

如果您安装了 RVM,您可能会因为安装了不同的版本而遇到错误。

检查并删除无用的版本,但我认为这不是好方法。反正错误消失了。

rvm list
rvm use ruby-version
rvm remove ruby-useless-version

刷新 cocoapods 后,应该在 .rvm GEM_HOME 中注入

gem uninstall cocoapods
gem install cocoapods

可能pod COMMAND会抛出关于minitestgem 的错误,所以——gem install minitest

于 2018-06-25T15:22:48.760 回答
4

In my case the warning itself has suggested the solution , so I just run them one by one.

Ignoring bigdecimal-2.0.0 because its extensions are not built. Try: gem pristine bigdecimal --version 2.0.0
Ignoring date-3.0.1 because its extensions are not built. Try: gem pristine date --version 3.0.1
Ignoring dbm-1.1.0 because its extensions are not built. Try: gem pristine dbm --version 1.1.0
Ignoring etc-1.1.0 because its extensions are not built. Try: gem pristine etc --version 1.1.0

Here an example:

gem pristine bigdecimal --version 2.0.0

so running the command of each line has solved my problem.

于 2021-01-27T10:57:48.407 回答
3

TL;DR - Ruby gems 不喜欢从符号链接运行或从构建位置移动的红宝石(因为嵌入的 shebangs)

如果调用 Ruby 目录或环境变量指向符号链接的目录,或者被复制或重命名,则可能会出现此消息。我正在使用 chruby 并且是符号链接/opt/rubies/-> /usr/local/ruby/,但是 Ruby 的动态库查找逻辑不能很好地解决这个问题。

在我的情况下,解决方案是用实际的红宝石替换符号链接并在每个 Ruby中/opt/rubies/运行。gem pristine --all对于使用 RVM 或 Rbenv 的其他人,祝你好运,无需从头开始。

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

于 2016-09-29T07:04:40.467 回答
3

Running Mac OS Catalina, brew and rbenv ...

Having come across this exact problem today, and gone through all the answers here I eventually stumbled across another reason for this error:

Ignoring nokogiri 1.10.7 because its extensions are not built. Try: gem pristine nokogiri --version 1.10.7

And of course gem pristine did no work.

My problem was a hard coded GEM_HOME and GEM_PATH environment variables which were overriding rbenv.

So, check that you haven't set GEM_PATH and GEM_HOME in ~/.zshrc

于 2020-02-06T11:45:58.290 回答
3

Most comments here are on the right track. This problem often occurs after a Ruby version upgrade. I reviewed the gem command code and here is the gist of it.

Extensions are compiled into the gems/gem/ext subdirectory of the gems home directory. For example, on my Cygwin installation (and similarly under Raspbian), the BigDecimal extension is compiled into /usr/share/gems/gems/bigdecimal-1.3.5/ext/bigdecimal/bigdecimal.so.

However, this is not where the extension is referenced when executed - that is from /usr/lib/gems/ruby/ver/gem. Again using BigDecimal, the extension file when executed is loaded from /usr/lib/gems/ruby/2.3.0/bigdecimal-1.3.5/bigdecimal.so

Here is the key: in this same directory, there is an empty tag file /usr/lib/gems/ruby/2.3.0/bigdecimal-1.3.5/gem.build_complete

When the gem command starts up, it refers to the gems/specifications directory to get a list of installed gems and information as to whether they have extensions. If a gem does have extensions, gem (among other sanity checks) looks for the tag file gem.build_complete. If that is not found, it emits the error message "Ignoring gem because its extensions are not built".

Any action which rebuilds all extensions will fix this problem. Or, as total hack, if you in a hurry and brave, you can try copying all contents of /usr/lib/gems/ruby/oldver to /usr/lib/gems/ruby/newver e.g.

cd /usr/lib/gems/ruby
cp -nv 2.3.0/* 2.6 
于 2021-02-19T17:47:26.417 回答
2

Libby 建议开始一个新的终端会话(她评论了 Sebastian Kim 的回答)对我有用。也比其他任何人都快得多,所以我想把它作为一个答案,这样它就更明显了。

于 2018-11-19T23:12:30.830 回答
2

这是一个旧线程,但我自己也遇到了这个问题。

你不需要重启你的机器,你只需要刷新你的环境,你可以使用 rehash 命令来做到这一点:

rehash

从手册页:rehash command re-computes the internal hash table of the contents of directories listed in the path environmental variable to account for new commands added.

于 2019-01-22T20:58:01.037 回答
2

当您在 Mac 上开发然后构建 Docker 映像时,这也是一个问题: https ://forums.aws.amazon.com/thread.jspa?messageID=879802&tstart=0

当您执行“bundle install --deployment”时,bundler 将创建一个供应商目录,其中包含您的 gem。请注意,虽然这包括本地文件夹中的 gem,但它只会包括您平台的本机扩展。当您在 macOS 上时,这将是 Darwin。您需要在 64 位 x86 linux 环境中重复该过程。

于 2019-02-16T16:31:44.280 回答
1

I had this problem but only when I was starting tmux session using tmuxinator.

Turned out it's because I'm using tmuxinator from brew instead of installing it using gem install. Maybe using chruby at the same time contributed to the problem as well.

p/s: I also removed unused ruby from ~/.gem/ruby but I doubt that's the reason this issue was resolved for me.

于 2020-01-28T00:45:31.090 回答
0

卸载和重新安装 Vagrant 也可以。安装程序 .dmg 映像中包含一个unistall.toolbash 脚本,它将删除 Vagrant。

在此处找到此解决方案:更新未内置的 Vagrant 和 Gems 扩展

于 2017-12-30T13:40:22.477 回答
0

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

rbenv 全球 2.5.1

于 2018-12-14T19:16:15.747 回答
0
于 2019-10-08T15:08:55.840 回答
0

This solution worked for me for RubyMine IntelliJ

I had two different terminals being used and RVM and ruby<Version>.

Solution:

I had to switch it to the RVM version for the errors to go away in Preferences>Languages&Frameworks>Ruby SDK

Errors:

Ignoring executable-hooks-1.6.0 because its extensions are not built. Try: gem pristine executable-hooks --version 1.6.0 rubymine

Ignoring gem-wrappers-1.4.0 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.4.0

enter image description here

于 2020-03-20T20:01:56.663 回答
0

If you are using rvm like me, the fix could a simple:

rvm get stable
rvm reload

As stated in this answer https://apple.stackexchange.com/a/192513

于 2020-10-22T17:22:31.830 回答
0

I have executed these commands in Terminal and worked for me:

  1. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. brew install ruby, it may need sudo (sudo brew install ruby).
  3. echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
  4. source ~/.bash_profile
  5. sudo gem pristine --all
于 2020-12-12T22:07:36.053 回答
0

In Ubuntu this worked for me.

  1. source ~/.bash_profile
  2. sudo gem pristine --all
于 2021-05-28T06:43:50.387 回答