ChatGPT解决这个技术问题 Extra ChatGPT

Ignoring GEM because its extensions are not built

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

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.

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 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.)

I am even seeing the same warning if the gems are not installed. I uninstalled bcrypt and it still gave me two warnings about it.
did you update bundler? uninstalling and reinstalling will just use whatever is in your Gemfile.lock. Bundler is the one who will build the extensions. Also, your output is listing multiple versions of gems so you should know this is system wide for that version of ruby (meaning you'll have multiple gems to rebuild).
I was in my home folder, not a Rails project, so there was no Gemfile.
Same issue happened to me (using rvm). gem pristine --all did not work. Solved by deleting all gems including bundler. Then installed bundler gem install bundler and finally navigated back to my project and ran bundle install which reinstalled all my gems and everything is working
In my case, it was caused by a vim extension. I did alias vim="rvm use system do vim" to work around it. But I only saw the warning when I exited vim so if you are seeing it in other situations this probably won't apply.

s
sevenseacat

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

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

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


This worked for me doing this only on the current ruby (I use rvm). Maybe this prevents someone from doing too much cleanup ;)
Sometimes gem pristine --all will do no good. See this answer on Ask Different for more info.
if gem pristine --all has permission issues, you should check which ruby. brew link --overwrite ruby && source ~/.bash_profile and run gem pristine --all may help
None of those solutions are working for me and I have this same issue.
gem pristine --all put me into several toubles, I strongly recommend not to use it without care
o
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.

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.


This did it for me. rm -rf. I'd previously tried to pristine install all of my gems to no avail.
This fixed it for me too after switching to asdf from ruby-install & chruby
this fixed sudo rm -rf ~/.gem/ruby/
Removing the cache folder under ~/.gem/ruby/ fixed the issue.
L
Luke Abel

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 managers installed and they overwrite each other and otherwise mess up your paths towards the gems.

The gem command also gets overwritten when you have rbenv and 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 implode
gem uninstall rvm
rm -rf ~/.rvm
rm -rf ~/.rvmrc

Here's what I did for rbenv

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

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;

rbenv rehash

Just removing the rvm related stuff fixed this problem for me on macOS
This solved my problem with msfconsole (aka metasploit)
S
Sebastian Kim

I did everything mentioned above including

xcode-select --install

reinstall ruby

reinstall all gems

gem pristine --all

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

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


Thanks for sharing the reboot tip. I had the same problem, on a Mac, and was able to resolve just by starting a new terminal session.
w
wrydere

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

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

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

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

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

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

sudo gem pristine bcrypt --version 3.1.12 (etc)

And finally the errors were gone.


Fantastic, that saved my day! I tried everything else mentioned before your answer, and it did not work. Only your procedure made it for me. Thanks!
D
Dave Ceddia

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


Just happened to me – thanks! It means that bundle install installed the gems (and their native extensions) for a the ruby selected via the RVM Ruby switcher, where a script referring to the system Ruby cannot find them. Your solution is the standard practice to make Ruby scripts and gems work with user installed rubies (see).
This put me on the right track! In my case, I wanted tmuxinator to be a util (not a bundled dep for a specific project), so I apt installed it on Ubuntu. So doing apt purge tmuxinator and then gem install tmuxinator made it work. I'll probably have to gem install it whenever I upgrade my non-project ruby version, but I like this better. Thanks!
I wish I could upvote this thrice. Solved it for me.
M
Marwen Doukh

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.


d
dimpiax

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

Check and remove useless versions, but I think this is not good approach. 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

gem uninstall cocoapods
gem install cocoapods

Probably pod COMMAND will throw the error about minitest gem, so – gem install minitest


佚名

TL;DR - Ruby gems don't like Rubies running from symlinks or moved from where they were built (because of embedded 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.

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

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


It turned out to be the running gem pristine --all on all of them part. Thanks for resurrecting this dead question. I was close to just burning it all down and starting over.
T
Tomm P

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


L
Lex Lindsey

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 

Y
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

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.


What OS are you talking about?
rehash or hash -r for bash is a shell command available on *nix. When the C shell starts, it builds a hash table of all the commands in its path: each command name and its absolute pathname. So, after you start a csh running, if new programs are added to directories along the path, you need to use the shell's rehash command to rebuild its hash table. (cf: docstore.mik.ua/orelly/unix3/upt/ch27_06.htm)
THIS! The point is that even with rbenv I had this issue but I forgot using rbenv rehash so the internals were still pointing to the system Ruby (macos) instead of the fresh installed one... so much for reading ;-)
N
NorseGaud

This is also a problem when you're developing on Mac and then build a Docker image: https://forums.aws.amazon.com/thread.jspa?messageID=879802&tstart=0

When you do a "bundle install --deployment", bundler will create a vendor directory w/ your gems in it. Note that whilst this includes your gems in the local folder, it will only include the native extensions for your platform. As you're on macOS this will be Darwin. You'll need to do repeat the process on a 64-bit x86 linux environment.


B
Bhargav Rao

Libby's suggestion to just start a new terminal session (which she commented on Sebastian Kim's answer) worked for me. Much quicker than any of the others too so I wanted to make it an answer so it was more visible.


A
Amree

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.


J
Jeff Wigal

Uninstall and reinstall of Vagrant also works. There's an unistall.tool bash script included in the installer .dmg image that will remove Vagrant.

Found this solution here: Updating Vagrant and Gems Extentions Not Built In


E
Eric Jones

I had the same issue and I'm using rbenv. For some reason my global rbenv setting went missing. In order to fix this problem I set the global version to one of my rbenv versions... for instance:

rbenv global 2.5.1


L
Luisa Hernández

On my case I was trying to run pristine --all but I was getting:

Ignoring ffi-1.11.1 because its extensions are not built.  Try: gem pristine ffi --version 1.11.1
Ignoring jaro_winkler-1.5.3 because its extensions are not built.  Try: gem pristine jaro_winkler --version 1.5.3
Ignoring psych-3.1.0 because its extensions are not built.  Try: gem pristine psych --version 3.1.0
/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': incompatible library version - /.gem/gems/psych-3.1.0/lib/psych.bundle (fatal) 

Then, I deleted the content on Users/{{user.name}}⁩/⁨.gem⁩ then as I needed to run bundle install --force, it reinstalled everything, then the command pristine --all worked as expected


R
Roger Perez

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

https://i.stack.imgur.com/BhlH4.png


l
lucasarruda

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


M
MrDEV

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

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew install ruby, it may need sudo (sudo brew install ruby). echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile source ~/.bash_profile sudo gem pristine --all


M
Mark Rutto

In Ubuntu this worked for me.

source ~/.bash_profile sudo gem pristine --all


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now