'gem install -v' installs wrong version of a gem - ruby

I'd like to install bundler v1.2.3 on my machine.
First, I checked out the remote gem repo whether that version of the gem exists:
$ gem list --remote | grep "^bundler "
bundler (1.2.3)
Then I tried to install the gem, but a different version(v1.1.5):
$ sudo gem install bundler -v '1.2.3'
Successfully installed bundler-1.1.5
1 gem installed
Installing ri documentation for bundler-1.1.5...
Installing RDoc documentation for bundler-1.1.5...
Why is this happening and is there any solution for this problem?
Thanks!

Just tested on my Mac running 10.8, worked no problem. I had Bundler 1.3.5 already installed.
andys-MacBook-Pro:.gem uw$ gem list 'bundler'
*** LOCAL GEMS ***
bundler (1.3.5)
andys-MacBook-Pro:.gem uw$ gem install 'bundler' -v '1.2.3'
Fetching: bundler-1.2.3.gem (100%)
Successfully installed bundler-1.2.3
Parsing documentation for bundler-1.2.3
Installing ri documentation for bundler-1.2.3
1 gem installed

I'm getting the gem (bundler 1.2.3) installed properly in my Win 7 32 bit machine. give a try again
C:\Windows\System32>gem install bundler -v 1.2.3
Fetching: bundler-1.2.3.gem (100%)
Successfully installed bundler-1.2.3
1 gem installed
Installing ri documentation for bundler-1.2.3...
Installing RDoc documentation for bundler-1.2.3...

When I used gem install bundler '1.2.3'
I got the following.
PS C:\Users\....> gem install bundler '1.2.3'
Fetching: bundler-1.2.3.gem (100%)
Successfully installed bundler-1.2.3
ERROR: Could not find a valid gem '1.2.3' (>= 0) in any repository
But it worked fine when I remove the quotation marks and just used
gem install bundler 1.2.3
EDIT ~ Didn't see the comment to the previous answer. Looks like this question is already solved.

I noticed that you use sudo to do the install but not to do the list. This can sometimes cause a problem, especially if you have multiple versions of ruby/gem installed (or if you use rvm).
I've also seen oddities like this if one of the gems is not using rubygems.org as the default gemserver. What does $ sudo gem list --remote | grep "^bundler " give you?
It may not matter but what version of ruby are you using?

Related

Unable to install bundler with gem

I am using ruby 2.6.5 and I try to install bundler -v 2.2.27 gem according to documentation using this command:
gem install bundler -v 2.2.27 --default
And this is the output I get:
gem install bundler -v 2.2.27 --default
Successfully installed bundler-2.2.27 as a default gem
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory # dir_chdir - /Users/jedrek/.rvm/gems/ruby-2.6.5/specifications/gems/bundler-2.2.27
It says it installed the gem but errors out at the same time :)
When I check current version of bundler I get this output
gem info bundler
*** LOCAL GEMS ***
bundler (2.2.32, 2.2.27, 2.2.24, 2.1.4)
Authors: André Arko, Samuel Giddins, Colby Swandale, Hiroshi
Shibata, David Rodríguez, Grey Baker, Stephanie Morillo, Chris
Morris, James Wen, Tim Moore, André Medeiros, Jessica Lynn Suttles,
Terence Lee, Carl Lerche, Yehuda Katz
Homepage: https://bundler.io
License: MIT
Installed at (2.2.32): /Users/jedrek/.rvm/gems/ruby-2.6.5
(2.2.27, default): /Users/jedrek/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0
(2.2.24): /Users/jedrek/.rvm/gems/ruby-2.6.5
(2.1.4): /Users/jedrek/.rvm/gems/ruby-2.6.5
As you can see it says that bundler -v 2.2.27 is installed.
When I try to install dependencies in my project I get this error:
bundle install
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (~> 2.2.27)
Current Bundler version:
bundler (2.1.4)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (~> 2.2.27)' in any of the relevant sources:
the local ruby installation
Listing current bundler version locally shows this output
gem list bundler
*** LOCAL GEMS ***
bundler (2.2.32, default: 2.2.27, 2.2.24, 2.1.4)
bundler-audit (0.7.0.1, 0.6.1)
capistrano-bundler (2.0.1, 1.3.0)
I am so confused. Is this is a bug?
I am using rubygems 3.2.27
gem --version
3.2.27
UPDATE
I tried upgrading rubygems to 3.2.32 and have the same issue.

How to fix "Warning: the running version of Bundler is older than the version that created the lockfile"

I have tried multiple times to uninstall bundler and reinstall bundler, and somehow, I keep seeing this error:
➜ gem uninstall bundler
Remove executables:
bundler
in addition to the gem? [Yn] y
Removing bundler
Successfully uninstalled bundler-2.0.1
➜ gem install bundler
Fetching: bundler-2.0.1.gem (100%)
Successfully installed bundler-2.0.1
1 gem installed
➜ bundle
Warning: the running version of Bundler (1.16.6) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Just uninstall and install again the required version in the warning, in your case it is requiring version 1.17.3
gem uninstall bundler
gem install bundler -v 1.17.3

after bundler installed with specific version why version of bundler did not change?

I got following error for bundle
Bundler could not find compatible versions for gem "bundler": In
Gemfile:
bundler (~> 1.15)
Current Bundler version:
bundler (2.0.1) This Gemfile requires a different version of Bundler. Perhaps you need to update Bundler by running gem install
bundler?
Could not find gem 'bundler (~> 1.15)' in any of the relevant sources:
the local ruby installation
then I tried to downgrade the bundler version with
$ gem install bundler -v '~> 1.7.0' Fetching: bundler-1.7.15.gem
(100%) Successfully installed bundler-1.7.15 Parsing documentation for
bundler-1.7.15 Installing ri documentation for bundler-1.7.15 Done
installing documentation for bundler after 1 seconds 1 gem installed
but when I recheck the bundler version with
bundler --version
it still said Bundler version 2.0.1
The default bundler version on your system is still 2.0.1. If you need to use the downloaded version 1.7.15, you would have to run bundle _1.7.15_ install. You could also check if that version was successfully installed on your system using bundle _1.7.15_ -v
In either case, if you get the error Could not find command "_1.7.15_", then that means that the bundler version _1.7.15_ has not been installed on your system.
Additionally, these links may help you:
Run specific version of bundler
Downgrade Bundler in RVM
Try updating bundle with bundler update bundler and run the bundle update again. It solved my problem the last time.

bundle install using wrong ruby with rvm when building native extension?

I'm using bundle install to install rest-client. It's failing with the following:
$ bundle
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing unf_ext 0.0.7.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/gems/unf_ext-0.0.7.4/ext/unf_ext
/usr/bin/ruby2.3 -r ./siteconf20180115-9722-1iow75n.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.4/gem_make.out
Installing mime-types-data 3.2016.0521
Installing netrc 0.11.0
Using bundler 1.11.2
An error occurred while installing unf_ext (0.0.7.4), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4'` succeeds before bundling.
I'm using rvm, which appears to be working correctly, if I'm reading the output from rvm info right.
which ruby reports /home/roger/.rvm/rubies/ruby-2.3.4/bin/ruby, which looks right.
I found Install ruby headers with rvm, but I have Ruby headers in (apparently) the correct place:
$ ruby -rmkmf -e 'print RbConfig::CONFIG["rubyhdrdir"]'
/home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
$ ls /home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
ruby/ ruby.h x86_64-linux/
In the output from bundle, I see /usr/bin/ruby2.3, which looks suspicious.
It's looking in the wrong place for Ruby header files. How do I get it to use the RVM-installed ones?
I was using the wrong bundle.
$ which bundle
/usr/bin/bundle
Either the one included in Ubuntu 16.04 is old, or using the system-installed bundler doesn't work with rvm-installed Ruby.
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
...
1 gem installed
$ which bundle
/home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/bin/bundle
That looks better.
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using bundler 1.16.1
...
Bundle complete! 1 Gemfile dependency, 9 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Lesson learned: when using rvm, remember to gem install bundler as well.

How to install therubyracer gem on 10.10 Yosemite?

I don't manage to install therubyracer gem on Yosemite 10.10.
Here is the log:
11:53 $ gem install libv8 -v '3.16.14.3' -- --with-system-v8
Building native extensions with: '--with-system-v8'
This could take a while...
Successfully installed libv8-3.16.14.3
Parsing documentation for libv8-3.16.14.3
Installing ri documentation for libv8-3.16.14.3
Done installing documentation for libv8 after 0 seconds
1 gem installed
02:05 $ gem install therubyracer -v '0.12.1' -- --with-system-v8
Building native extensions with: '--with-system-v8'
This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
/usr/local/var/rbenv/versions/2.1.2/bin/ruby extconf.rb --with-system-v8
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/var/rbenv/versions/2.1.2/bin/ruby
--with-pthreadlib
--without-pthreadlib
--with-objclib
--without-objclib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in `configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError)
and *not* the one that is bundle with the libv8 rubygem. However,
it could not be located. please make sure you have a version of
v8 that is compatible with 3.16.14.3 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location
thanks,
The Mgmt
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `'
extconf failed, exit code 1
Gem files will remain installed in /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/therubyracer-0.12.1 for inspection.
Results logged to /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/therubyracer-0.12.1/gem_make.out
gem uninstall libv8
brew install v8
gem install therubyracer
gem install libv8 -v '3.16.14.3' -- --with-system-v8
this is the only way it worked for me on 10.10 (ruby 2.1.2)
Or try gem install libv8 -v 'XX.XX.XX' -- --with-system-v8 adding the version of the gem :)
UPDATE for Mac OS Catalina:
brew tap homebrew/versions
brew install v8#3.15
brew link --force v8#3.15
gem install libv8 -v 'XX.XX.XX' -- --with-system-v8
gem install therubyracer
git clone https://github.com/cowboyd/libv8.git
cd libv8
bundle install
bundle exec rake clean build binary
gem install pkg/libv8-3.16.14.3-x86_64-darwin-12.gem #note that libv8 version may change, so tab through files in pkg/, also remember to use the one with version specified
then just bundle your project gems
this is the only way it worked for me on 10.10 (ruby 2.1.2)
None of the answers work for me this time. I have too use this:
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
Seen on the rubyracer Github issues.
Hope it helps someone else.
Maybe it will be useful for someone but I had problems installing therubyracer (because of the problems with libv8) the solution was to uninstall all the libv8 that I had installed. Install therubyracer
$ gem uninstall libv8
$ gem install therubyracer -v '0.12.0'
Fetching: libv8-3.16.14.7-x86_64-darwin-14.gem ( 57%)
Fetching: libv8-3.16.14.7-x86_64-darwin-14.gem (100%)
Successfully installed libv8-3.16.14.7-x86_64-darwin-14
Building native extensions. This could take a while...
Successfully installed therubyracer-0.12.0
2 gems installed
I hope this helps someone.
It seems like this has been fixed upstream. What worked for me and #aurels and #Mike Causer and #Juanda was:
bundle update libv8
This worked for me very well on my Yosemite and Ruby 2.1.5 (Ruby through RVM)
gem install libv8 -v '3.16.14.3' -- --with-system-v8
Earlier it was giving me error Gem::Ext::BuildError: ERROR: Failed to build gem native extension. for libv8 gem version 3.16.14.3
Only this works for me in my Yosemite, Ruby 2.1.2:
gem install libv8 -v '3.16.14.3' -- --with-system-v8
brew link --overwrite v8-315 --force
gem install therubyracer -v '0.12.2' -- --with-system-v8
I was able to proceed with ruby racer after rm Gemfile.lock
beforehand:
I installed v8 via brew install v8, and then did gem install libv8 -v '3.16.14.3' -- --with-system-v8
and I am running 10.10 Yosemite
They have corrected this issue in the most recent version of libv8. See: https://github.com/cowboyd/libv8/issues/123
You should install from the github repo, in rails I added a line to my gemfile like this gem "libv8", git: "git://github.com/cowboyd/libv8.git", submodules: true
EDIT:
This apparently only solves some of the problem. I installed the new version of libv8, but now the rubyracer is still looking for the other one I think? Still looking into it.
I had the same issue on Yosemite. My solution is similar to what appears above.
Use gem uninstall libv8 to remove anything that might be installed.
Leave therubyracer in your Gemfile, but remove any explicit reference to libv8.
Run bundle install.
libv8 then installed fine as a dependency.
Updated answer for 2018.
I'm on High Sierra, on Homebrew 1.6.1
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8#3.15/
Is what worked for me.
Credit goes to #coding-addicted for his original answer.
After hours of trying simply upgrading ruby worked:
brew install ruby
and then adding the following to gem file:
gem 'libv8'
gem 'therubyracer'
A heads up to anyone that might have been having my issue: I ended up uninstalling my ruby version in RVM and then reinstalling it. That seemed to use the correct dependancies in the latest version of xcode tools for compiling ruby.
rvm list
rvm uninstall ruby-x.x.x
rvm install ruby-x.x.x
I did the following
gem install therubyracer
which now installs therubyracer 0.12.1 which installs the dependency libv8 (3.16.14.7 x86_64-darwin-14) which installed with no errors.
I did this using ruby 2.1.5 which I installed via:
CC=/usr/bin/gcc rbenv install 2.1.5
which I did after running brew upgrade ruby-builds.
After installing ruby 2.1.5, I also ran
gem upgrade --system
to get rubygems-update 2.4.5
this happens due to some conflicts with the libv8 as well, although you can just assign a version to the rubyracer and it will be installed:
change the following in the gemfile:
gem 'therubyracer', '~> 0.12.1'
and do bundle install
What worked for me, based on the following comment,
https://github.com/cowboyd/therubyracer/issues/304#issuecomment-62046085
was to remove Gemfile.lock and then run bundle install
This solution worked for me following Jakub Troszok's solution above with just a minor change
gem uninstall libv8
gem install therubyracer -v '0.12.1'
Fetching: libv8-3.16.14.19-x86_64-darwin-18.gem (100%)
Successfully installed libv8-3.16.14.19-x86_64-darwin-18
Building native extensions. This could take a while...
Successfully installed therubyracer-0.12.1
Parsing documentation for libv8-3.16.14.19-x86_64-darwin-18
Installing ri documentation for libv8-3.16.14.19-x86_64-darwin-18
Parsing documentation for therubyracer-0.12.1
Installing ri documentation for therubyracer-0.12.1
Done installing documentation for libv8, therubyracer after 0 seconds
2 gems installed
gem install libv8 -v '3.16.14.17' -- --with-system-v8 (if the libv8 version required for your project is different from the one installed by rubyracer)
bundle install
Using homebrew's directory of v8 for --with-v8-dir=/usr/local/Cellar/v8#3.15/3.15.11.18_1, instead of /usr/local/opt/v8-315, is what worked for me, in coding addicted's answer.
This is visible in the Summary of the brew install command, brew install v8-315.

Resources