ruby 忽略 GEM,因为它的扩展没有构建

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38797458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:51:01  来源:igfitidea点击:

Ignoring GEM because its extensions are not built

rubyrubygemschruby

提问by Phillip Longman

On both my work and home computers, I recently upgraded Ruby to 2.3.1, using ruby-install. I use chrubyas my Ruby switcher.

在我的工作和家用计算机上,我最近使用ruby-install. 我chruby用作我的 Ruby 切换器。

I started seeing this warning in my terminal:

我开始在终端中看到此警告:

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

On my work, computer, the list was much longer, but easy to resolve. When I tried the suggested gem pristine GEM, it told me it couldn't find the gem, so I ran gem install GEM, and that solved it.

在我的工作计算机上,列表要长得多,但很容易解决。当我尝试建议时gem pristine GEM,它告诉我它找不到宝石,所以我跑了gem install GEM,然后解决了它。

At home, nothing is working.

在家里,什么都不起作用。

Things I have tried, from common sense and various other Stack questions:

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

  • 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 XCodeand letting it install some extensions (It did need to do it, but it didn't fix anything.)
  • running brew doctorand solving all the minor issues, then brew updateand 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.)
  • gem pristine GEM
  • gem pristine --all
  • 卸载并重新安装 gem
  • gem update
  • gem update --system
  • bundle update
  • 卸载并重新安装 bundler
  • 卸载和重新安装rails(虽然,这不是 Rails 特定的问题。)
  • 删除 ~/.bundle/
  • 打开XCode并让它安装一些扩展(它确实需要这样做,但它没有解决任何问题。)
  • 运行brew doctor和解决所有的小问题,然后brew updatebrew upgrade
  • gem install curb(我无法想象这个 gem 与这个问题有什么关系,但是两个不同的人将它列为他们修复同一警告的最后一步。)

回答by sevenseacat

I came across this exact issue today - getting warnings like this for gems that weren't even installed!

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

... Well, it turns out the gems wereinstalled - for a different ruby than the one I had set active with chruby (2.2.3 vs 2.3.1).

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

Switching to all the different rubies and running gem pristine --allon all of them solved the problem.

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

回答by opes

I ran into this issue and followed all the same commands as above, even going so far as to remove all my previously installed Ruby versions. However, the error persisted.

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

Turns out, there were some leftover gems for the various (previously uninstalled) versions in ~/.gem/ruby/. After removing the folders I no longer used, the errors disappeared.

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

回答by Simon Somlai

I've had this problem today too and it frustrated because I couldn't type because my whole editor flashed red with error messages.

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

I'm not entirely sure what exactly caused it but I believe it's because we have multiple ruby versions OR multiple ruby version managersinstalledand they overwrite each other and otherwise mess up your paths towards the gems.

我不完全确定究竟是什么导致了它,但我相信这是因为我们安装了多个 ruby​​ 版本或多个 ruby​​ 版本管理,它们会相互覆盖,否则会扰乱您通往 gem 的路径。

The gemcommand also gets overwritten when you have rbenv and rvm.

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

See which ones you've installed by typing;

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

which rvm
which rbenv
which chruby

If one of those is installed it'll return a path. Then delete them, make sure to completely clean out all the directories and start with a clean install.

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



Remove

消除

Here's what I did for rvm;

这是我为rvm 所做的

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

Here's what I did for rbenv

这是我为rbenv 所做的

First installed https://github.com/meowsus/rbenv-clean, then

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

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

Reinstall

重新安装

Then you have a clean home directory to work from. I re?nstalled rbenv with How to install Ruby 2.1.4 on Ubuntu 14.04. And finally;

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

rbenv rehash

回答by Sebastian Kim

I did everything mentioned above including

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

  • xcode-select --install
  • reinstall ruby
  • reinstall all gems
  • gem pristine --all
  • xcode-select --install
  • 重新安装红宝石
  • 重新安装所有宝石
  • 宝石原始 - 全部

but the issue was the same for me. I just rebooted my Mac as the last hope, and the warning messages are disappeared.

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

Weird, but if anyone's struggling with this issue after trying everything on StackOverflow, try reboot your machine.

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

回答by dimpiax

If you have installed RVM, possible you're catching the error because you have installed different versions.

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

Check and remove useless versions, but I think this is not goodapproach. Anyway errors gone.

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

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

After refresh cocoapods, it should be injected in .rvm GEM_HOME

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

gem uninstall cocoapods
gem install cocoapods

Probably pod COMMANDwill throw the error about minitestgem, so – gem install minitest

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

回答by dimpiax

TL;DR - Ruby gems don't like Rubies running from symlinks or moved from where they were built (because of embedded shebangs)

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

If the Ruby directory is invoked or environment vars point to a symlink'ed directory, or are copied or renamed, this message is likely. I am using chruby and was symlinking /opt/rubies/-> /usr/local/ruby/, but Ruby's dynamic library-finding logic doesn't play well with this.

如果调用 Ruby 目录或环境变量指向符号链接目录,或者被复制或重命名,则可能会出现此消息。我正在使用 chruby 并进行符号链接/opt/rubies/-> /usr/local/ruby/,但是 Ruby 的动态库查找逻辑在此方面效果不佳。

The solution in my case was to replace the symlink with actual rubies in /opt/rubies/and run gem pristine --allin each Ruby. For others using RVM or Rbenv, good luck with that without starting over from scratch.

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

This may not be your exact issue, but hopefully it helps.

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

回答by wrydere

Adding my own flavor here. I use rbenvinstalled via Homebrew and was getting four of these "ignoring... extensions not built" messages. Specifically:

在这里添加我自己的味道。我使用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

I tried many things in this thread with no luck. Finally in my case I did:

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

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

At this point I was still getting the errors, but now I had only a single Ruby version to contend with:

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

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

At this point I tried sudo gem pristine --allbut was rejected for permissions on the system Gems directory.

在这一点上,我尝试过sudo gem pristine --all但由于系统 Gems 目录的权限而被拒绝。

So I went through and ran pristine on each gem, like

所以我经历并在每颗宝石上运行原始,就像

sudo gem pristine bcrypt --version 3.1.12(etc)

sudo gem pristine bcrypt --version 3.1.12(等等)

And finally the errors were gone.

最后错误消失了。

回答by yacc

This is an old thread, but I just came across this issue myself.

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

You don't need to restart your machine, you just need to refresh your environment, you can do this with the rehash command:

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

rehash

From the man page: 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.

从手册页: 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.

回答by Dave Ceddia

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

运行一开始gem pristine --all并没有帮助,但后来我意识到:我正在运行的脚本从以下行开始:

#!/usr/bin/ruby

#!/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 --allwas fixing up the RVM installation, but my script was calling a different version of Ruby.

在我的 macOS 系统(Catalina,但我认为这无关紧要)上,这指向系统附带的 Ruby,而不是 RVM 安装的那个。运行gem pristine --all正在修复 RVM 安装,但我的脚本正在调用不同版本的 Ruby。

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

对我来说,修复方法是使用该env命令调用当前 shell 的PATH. 将脚本的第一行更改为此修复了它:

#!/usr/bin/env ruby

#!/usr/bin/env ruby

回答by Tomm P

Running Mac OS Catalina, brew and rbenv ...

运行 Mac OS Catalina、brew 和 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

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.

当然, gem pristine 没有用。

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

我的问题是一个硬编码的 GEM_HOME 和 GEM_PATH 环境变量,它们覆盖了 rbenv。

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

因此,请检查您是否没有在 ~/.zshrc 中设置 GEM_PATH 和 GEM_HOME