Vagrant can't see my rbenv gems - ruby

I removed an old copy of vagrant according to the official HashiCorp docs, and reinstalled using the official OSX universal installer. Now, every vagrant command on the host returns the following warning:
$ vagrant global-status
Ignoring ffi-1.9.10 because its extensions are not built. Try: gem pristine ffi --version 1.9.10
I doublechecked my Ruby setup, and found RVM and rbenv both installed. So, I uninstalled RVM with rvm implode, and deleted ~/.rvm for good measure. Lastly, I installed Ruby 2.3.0 with rbenv, and called rbenv init (and added its output to my shell config).
From here, I have a setup that will let me install any version of ffi. The latest version is newer than 1.9.10, but installing 1.9.10 doesn't affect the warning.
I assume lacking FFI is going to slow things way down. How do I get Vagrant to use the rbenv-managed gems?

Related

Ignoring ffi-1.13.1 because its extensions are not built. Try: gem pristine ffi --version 1.13.1

When I installed cocoa pods I got this message. The cocoa pods downloaded is in version 1.10.1. Ive tried to use the command they give but this appears:
Ignoring ffi-1.13.1 because its extensions are not built. Try: gem pristine ffi --version 1.13.1
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
Does it means that the latest version available is 1.13.1 but I can't use it because of a problem? How to solve it?
This solved the issue for me
brew install cocoapods
should already be linked (as pointed out by Raphael Pinel) but if you want to make sure run
brew link --overwrite cocoapods
Basically, you need to do what the warning message says: install the Gem "ffi" in the specified version by running gem pristine ffi --version 1.13.1. However, usually you don't have write permissions on the system to install a Gem into the stated directory.
You could probably just use sudo, i.e. run the command sudo gem pristine ffi --version 1.13.1 and enter the password, but I guess this is generally not recommended as it is a security risk.
I installed it like this:
gem install ffi --version 1.13.1 --user-install
Then I had to add the installation path to my PATH variable; in my case I added this line to my ~/.zshrc:
export PATH=$HOME/.gem/ruby/2.6.0/bin:$PATH
I'm really not an expert on Ruby stuff, but this solved the issue for me.
This worked for me :
sudo gem pristine ffi (don't write a version here, because it will fix the problem of all versions)
then :
pod install
MacOS: Ventura v13.0
Updating the Ruby version worked like a charm. Did the following steps.
$ brew install rbenv
Installed the latest ruby version.
$ rbenv install 3.1.2
To activate the above version as global default version.
$rbenv global 3.1.2
To install ffi
$ sudo gem install ffi --version 1.15.5 --user-install
in my case ( mbpm1 pro ) , my other project are fine , but some project from my friend ( windows only) i got some issue , i fixed by
arch -x86_64 sudo gem install ffi
flutter clean dont forget to clean after installing some gem
flutter pub get re get
run now ( these run would automatically run pod install ) just click on main.dart ( vscode )
None of the answers worked for me. So, I thought of uninstalling all versions of ruby which I had unknowingly installed, and keeping only the one installed by Xcode.
brew uninstall --force ruby
Then, uninstalled cocoapods
brew uninstall --force cocoapods
I was left with the ruby installed by XCode. I ran:
gem pristine ffi --version 1.15.3
I realised the other versions got installed in ~/.local
I deleted the whole folder as it had nothing other than the old gem folder
rm -rf ~/.local
Now, reinstall cocoapods:
brew install cocoapods
Try running:
pod install
OR
gem -v
You should not see this error.
This usually happens when you have multiple gem versions installed and the path is incorrect.
P.S I am using macOS Monterey 12.1
My issue was that the pre installed ruby had those extensions installed and caused the error messages. Run the command below to
see all installed packages. Said command should also print the error Ignoring ... because its extensions are not built. Directly reference /usr/bin/gem since you might have ruby installed via brew which would be called otherwise.
/usr/bin/gem list
Then manually uninstall all mentioned extensions for the default ruby.
sudo /usr/bin/gem uninstall ffi
In my case I had paths mismatch, this command helped me:
rvm get stable --auto-dotfiles
Also check paths order in you .zshrc file
f.e.
# Ruby
export PATH="~/.rvm/gems/ruby-2.6.0/bin:$PATH"
export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
# User local
export PATH="/usr/local/bin:$PATH"
gem install cocoapods
This is a workaround and not a solution, but for me, after trying all other posted solutions (on Monterey 13.0.1, I traced it back to it seemingly picking the homebrew installed cocoapods picking up the ffi library from ~/.rbenv/shims, with the only timely work around being to install cocoapods via gem, per above.
All this said, I don't claim to be well versed in rbenv, or any other dependency manager, for that matter.
I'd love to know a better answer that didn't bork the homebrew based installation.
Start the Terminal on a Mac M1 with Rosetta and run
pod update

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 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.
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.
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
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.
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.
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
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.
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
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
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.
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.
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
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.
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.
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.
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
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
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
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
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
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
In Ubuntu this worked for me.
source ~/.bash_profile
sudo gem pristine --all

Fix for: Prior to 0.1.6, libyaml is vulnerable to a heap overflow exploit from malicious YAML payloads

I get the following error when running rspec after I added the vcr gem. Simply running gem install psych -- --enable-bundled-libyaml as suggested doesn't solve the problem. I am using rbenv and ruby-build and I am on ruby 2.1.1. What do i have to do to fix this?
SafeYAML Warning
----------------
You appear to have an outdated version of libyaml (0.1.4) installed on your system.
Prior to 0.1.6, libyaml is vulnerable to a heap overflow exploit from malicious YAML payloads.
For more info, see:
https://www.ruby-lang.org/en/news/2014/03/29/heap-overflow-in-yaml-uri-escape-parsing-cve-2014-2525/
The easiest thing to do right now is probably to update Psych to the latest version and enable
the 'bundled-libyaml' option, which will install a vendored libyaml with the vulnerability patched:
gem install psych -- --enable-bundled-libyaml
First, you have to update Ruby-build, they have recently patched this security issue. Now, it installs libyaml 0.1.6 to compile Ruby.
$ rm -rf ~/.rbenv/plugins/ruby-build
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
Recompile, reinstall the Ruby version you are using, 2.0.0-p451 in my case:
$ rbenv install 2.0.0-p451
rbenv: /home/ubuntu/.rbenv/versions/2.0.0-p451 already exists
continue with installation? (y/N) y
Downloading yaml-0.1.6.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/5fe00cda18ca5daeb43762b80c38e06e
...
And it worked in my case.
I just followed the instructions in this reply https://stackoverflow.com/a/9510209/816002 and it seems to have done the trick. I did it slightly different however:
rvm pkg install libyaml
rvm get stable
rvm reinstall all --force
This might not help if you are using system Ruby, and will obviously be different with rbenv.
As a user of rvm, I managed to get my set up to play ball by building 0.1.6 release of libyaml, then (re)installing Ruby, passing the following configure flag
rvm install 1.9.3 -- --with-libyaml-dir=/usr/local
Hope this helps people in the short-term until the dust settles.
If you're on Mac OS X / Mavericks then you may be running on the system-installed Ruby. Thoughbot encourages you not to do this. I was having this problem as well, so I followed their advice and installed brew and rbenv and the problem went away.
For rvm this worked for me:
rvm pkg install libyaml
$LIBYAML_PATH will be the path where RVM installs the upated yaml
rvm get stable
rvm reinstall all --force --with-libyaml-dir=$LIBYAML_PATH
http://synaptian.com/2014/04/fixing-the-safeyaml-warning-on-ubuntu-12-04-with-rvm/

Bundler::GemfileNotFound whenever I try to run bundle install

I'm working in kali-linux (a linux distro witch is the continuation of Back-Track, based in Ubuntu, just that now is based on Debian wheezy) for some penetration testing. Everything was working just fine, until I decided to update my systems tools. Now whenever I try to run a tool based on ruby, it trows me:
Could not find gem 'ruby-progressbar (>= 1.1.0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
I proceed to run bundle install but then it comes with Bundler::GemfileNotFound error.
Kali use by default ruby, for using gems. The software don't 'require' any other package but ruby seems not-fully-configured/installed for the problem at hand.
$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [i486-linux]
$ rvm
bash: rvm: command not found
$ rbenv
bash: rbenv: command not found
I faced the same problem when I was trying to bundle install without realizing that I was not in the project directory. Make sure you're in the current project directory.
to avoid this error you should be at the root of your application and create GemFile and specify all gems needed in there, and run bundle install
The problem was that for some weird motive Ruby didn't detected that bundler was installed, although the package manager says so.
$ apt-cache policy bundler
bundler:
Installed: 1.3.5-2
Candidate: 1.3.5-2
$ bundle --version
Bundler::GemfileNotFound
I simply run gem install bundler then bundler install as root in the tool root path and everything works as charm.
Do you use rvm or rbenv? If so, make sure you are using a particular ruby version.
For rvm, rvm list and look for an indication next to your ruby version. If the correct one is not listed, run rvm install x.y.z. If the correct one is not selected, run rvm use x.y.z
If you want to segregate your gems for a given project, create a gemset. Otherwise, you should be good to go.
Run gem install bundler. You should not have to do this as sudo. This will install bundler in either the Default rvm gemset, or the selected gemset.
Bundler should now be available and can be run using bundle. This is the same as bundle install.
Try this:
sudo ln -s /var/lib/gems/1.8/bin/bundle /bin/bundle
sudo ln -s /var/lib/gems/1.8/bin/bundler /bin/bundler
Worked for me in debian.

reinstall every gem for each ruby version?

I just installed Ruby 2.0.0 using rbenv and set it to the global ruby version for my system. Since 2.0 is compatible with 1.9.3, I tried to start up a Rails project with it, but got the following error. I did rbenv rehash after installing 2.0
The `rails' command exists in these Ruby versions:
1.9.3-p327
Does this mean that every gem I installed on my system with 1.9.3 has to be reinstalled if I wish to use it with 2.0?
As seen here:
You need to reinstall bundler for each version of Ruby you use. See Ruby versions where you have it installed:
rbenv whence bundle
See your current version:
rbenv version
Install bundler for that version, if missing:
gem install bundler
Yes. Rbenv (and RVM) have separate "gem home" directories for each installed version of Ruby. There may be ways to symlink certain directories to get them to share, but this will likely lead to problems, particularly with gems that include native C extensions, which may or may not compile and run cleanly in multiple versions.
If you have a Gemfile, easiest thing is to just bundle install again for Ruby 2.0, giving you duplicate copies of many gems and Ruby-2.0 compiled versions of any native gems.
Another solution to this is to copy (or reinstall) the gems from your previous version to the newly installed version. How to do that is answered in detail in this question, which has two scripts -- one to install from local cache, one to reinstall from the internet (mine).

Resources