I am trying to run a bundle install in my Ruby project. But it tries to install rake -v 11.1.2 which requires Ruby 1.9.3. (I am using 1.8.7-p374 - please don't kill me!)
None of my Gemfiles have this version specified and I already have rake version 10.1.1 installed. I want to know which other gem needs this particular version.
Here is my gem dependency -R output => http://pastebin.com/BqTnPYvf
Can anyone please guide me through this?
There are some answers saying using gem 'cocoapods', '0.33.1' or gem 'pod', '0.33.1
but this does not work.
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command cocoapods,
In one project I need to use 0.33.1, but 0.34.4 in another. How do I switch the cocoapods version quickly on command line? I don't want to use gem install or uninstall.
I am using rbenv with ruby version 2.0.0p0. Keep using rbenv is preferred but I can switch to rvm or pure ruby only if there is no other options.
Thanks.
You can do the following to use different versions:
pod _0.34.4_ install
or
pod _0.34.1_ install
This is precisely the purpose of Bundler
In one project, you specify this in the Gemfile:
gem 'cocoapods', '0.33.1'
along with all other gems.. and run bundle install to install them.
There are some other steps to make sure you load those gems from bundler, I'd read that site for the full documentation.
Rails projects have this already set up for you, but if this is a plain old ruby project, you have to wire it up yourself.
FYI I am using the following temp solution.
Since I am using rbenv, I install different versions of cocoapods under different version of ruby.
For example,
rbenv global 2.1.0
gem install cocoapods -v 0.34.4
rbenv global 2.0.0-p0
gem install cocoapods -v 0.33.1
When I work on different Xcode projects that requires different version of Cocoapods, I just switch ruby version on the fly, and Cocoapods version is switched accordingly.
As I mentioned these are xCode projects and we are not allowed to add gemfile or install gem in the project folder. So this works for me.
I'm using a very old version of SASS (3.1.15) in the Compass framework, and I want to upgrade to 3.4.3, which is the latest. I'm researching the process of upgrading, and after reading the SASS changelog, I'd like to be able to upgrade, then if I see a lot of errors and whatnot, revert back to the old version since I currently have actual development work to do in parallel with this research. I want to avoid being blocked due to legacy code being incompatible with new SASS, but I also want to see what issues an upgrade would bring, if any. Is there a way to do this?
I believe it would be as simple as this to upgrade:
$ sudo gem uninstall sass
$ sudo gem install sass --version 3.4.3
Then if you want to switch back to the old version:
$ sudo gem uninstall sass
$ sudo gem install sass --version 3.1.15
Both Bundler and RVM allow you to specify gems in their own way. Bundler is project-based, while RVM uses gemsets.
When I try to bundle install I get the following message:
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.0
In my Gemfile I have the following:
ruby '2.1.0'
And when I run ruby -v in the console I get:
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0]
What does Ruby 2.1.0p0 mean? What version should I have in my Gemfile and why does the error tell me I have Ruby version 2.0.0?
Run
gem install bundler
or
gem update bundler
which may fix your problem.
For all new installed versions of Ruby you should update or install a new bundler.
In the top-level directory of your project, create a file named .ruby-version containing (wait for it...)
2.1.0
That apparently is the cross-{rbenv,rvm} way of spec'ing the version now.
For me, none of the answers helped. I fixed it closing and opening again the terminal.
If you get this in a Rails project, and you recently upgraded your Ruby version you might have spring still running with the old version of Ruby.
./bin/spring stop
will fix this.
None of the other suggestions was working for me. On the server, I had to do:
rvm --default use [correct version number]
brew cleanup ruby worked for me as I use HomeBrew to install Ruby.
I recently updated Ruby through HomeBrew but HomeBrew did not remove the older version. brew cleanup ruby will delete the older version of Ruby.
the main reason for this problem is your machine and gemfile using a different ruby version
so there is multiple problems and solutions for this issue you can try the below solutions one by one
1- make sure your machine install and use the same version of your gemfile if your machine not using the same one try to install this version using rvm
$ rvm install ruby_version_you_want
make sure the version installed success by using this command
$ rvm list
and if the new version doesn't set as a default you can set it using this command
$ rvm --default use ruby_version_you_want
you can check the current ruby version
$ rvm current
$ ruby -v
2- if you have the same issue check your bundler
$ gem install bundler
or
$ gem update bundler
3- in some cases spring still using the old version so you need to stop it
$ ./bin/spring stop
4- another case you can type
$ gem pristine --all
and try to install bundle again
5- also in some cases after install the updated ruby version you just need to restart your terminal.
6- another solution but I didn't recommend it the top-level directory of your project, create a file named .ruby-version containing your active running ruby version
7- if you still have this problem try to remove ruby and install the updated version only
$ aptitude purge ruby
If you are using Capistrano you should also check your deploy.rb file for the set :rbenv_ruby configuration.
I got this after upgrading with ruby-install. Fixed this with:
gem install bundler
followed by:
$HOME/.rubies/ruby-2.4.1/bin/bundle
It shouldn't be necessary to specify the path as which bundle indicates it's already using this path. But it gives the version error if running bundle without the path. I don't know why?
Thanks for the info about installing / updating bundler but it didn't work for me.
I had to do rbenv rehash
If you are using rbenv to manage your ruby environments you can run rbenv local 2.1.0 within your project directory to set the version of ruby your gemfile asks for.
NONE of the above answers worked for me, but
$ gem pristine --all
did the trick for me
buona fortuna
I struggled with something very similar, just different versions. I finally fixed it by going to RubyGems and placing the latest version of bundler in my gemfile, which currently is:
gem 'bundler', '~> 2.1', '>= 2.1.4'
There was still an issue, but after that, I ran:
gem update --system
And it resolved the mixed-up versions of Ruby in the rails project folder. You may have to restart the terminal before you do this. Also, I commented out the bundler gem file, it appears the gem update --system command is what really resolved it.
I got it from here:
For more advanced projects .versions.conf is supported, where more than the Ruby version can be specified.
Generating .versions.conf:
rvm --create --versions-conf use 1.9.3#my_app
Example .versions.conf:
ruby=jruby-1.6.8
ruby-gemset=my_app
env-JRUBY_OPTS=--1.9
Make sure your server configuration points to the correct ruby installation.
I had already updated my Ruby version in the .ruby-version file and that didn't fix it. ruby -v also showed the correct version, but I had forgotten to update my server config.
For example, with rbenv, NGINX, and Pushion Passenger I had in my NGINX server block:
passenger_ruby /Users/myusername/.rbenv/versions/2.3.1/bin/ruby;
And I needed to change to...
passenger_ruby /Users/myusername/.rbenv/versions/2.3.3/bin/ruby;
Then restarted NGINX and it worked.
This could happen when you install new version of ruby and update .ruby-version and Gemfile to the new version without doing install all the gems for new version of ruby first. So do the
$ bundle install
and you might as well need to source .profile or restart your shell.
If you are using rbenv just run
rbenv local 2.0.0
Then
bundle install
I opened Gemfile and replaced 2.7.1 with my own version of ruby 2.7.0 Everything is okay right now.
Had the same problem and I'm working with rbenv
Those are the steps that helped me fix my problem:
First in terminal, type which bundle. For me this gave: /usr/local/bin/bundle
Again in terminal try which ruby. In my case this gave: /Users/Mahmoud/.rbenv/shims/ruby
The problem here thus is that bundle isn't using the same ruby version from rbenv. So the path needs fixing. In other words I need to tell my terminal to use the rbenv version of bundle when I use bundle install.
So step 3: For me I personally already had the path set in ~/.bash_profile:
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
but apparently this was not enough as I was using zsh. Had to add those same 2 lines to ~/.zshrc as well.
Restart terminal
Now bundle install is working as expected and which bundle gives:
/Users/Mahmoud/.rbenv/shims/bundle
indicating that the problem was just that bundle was using the wrong ruby.
So if you have this problem, just make sure ~/.bash_profile and ~/.zshrc have the correct path by adding the 2 lines indicated above. If this didnt work take a deep dive into paths to make sure that before starting which bundle gives the equivalent of:
/Users/Mahmoud/.rbenv/shims/bundle
Had the same error. Doing the following fixed it. I was using ruby 2.5.5 and rbenv. Upgraded from 2.5.1.
rbenv rehash
gem uninstall bundler
gem install bundler
gem install bundler:1.17.3 (my app needed specific bundler -v 1.17.3)
gem install rails
I solved this problem by updating my ruby version to ruby '2.4.0'
Then bundle install
Simply closing the terminal I was working on and opening a new one worked for me. Sometimes, updates are not effected immediately until a session is closed. I have found this as the case with many rails errors I faced.
I clean and install with that:
sudo gem pristine --all
and install again:
bundle install
I face the error msg
Your Ruby version is 2.5.1, but your Gemfile specified 2.3.0
and solved by the following steps:
open Gemfile which located at your directory.
change ruby '2.3.0' to ruby '2.5.1' and save the Gemfile
go back to items and run bundle update.
the issue is perfectly solved.
I am trying to install the ibm_db gem so that I can access DB2 from Ruby. When I try:
sudo gem install ibm_db
I get the following request for clarification:
Select which gem to install for your platform (i486-linux)
1. ibm_db 0.10.0 (ruby)
2. ibm_db 0.10.0 (mswin32)
3. ibm_db 0.9.5 (mswin32)
4. ibm_db 0.9.5 (ruby)
5. Skip this gem
6. Cancel installation
I am always going to be installing the linux version (which I assume is the "ruby" version), so is there a way to pick which one I will install straight from the gem install command?
The reason this is a problem is that I need to automate this install via a bash script, so I would like to select that I want the "ruby" version ahead of time.
You can use a 'here document'. That is:
sudo gem install ibm_db <<heredoc
1
heredoc
What's between the \<\<\SOMETHING and SOMETHING gets inputted as entry to the previous command (somewhat like ruby's own heredocuments). The 1 there alone, of course, is the selection of the "ibm_db 0.10.0 (ruby)" platform.
Hope it's enough.
Try this:
sudo gem install --platform ruby ibm_db
Note that you can get help on the install command using:
gem help install
UPDATE: Looks like this option only works for RubyGems 0.9.5 or above.
Try this, I think it only works on Bash though
sudo gem install ibm_db < <(echo 1)
#John Topley
I already tried gem help install, and --platform is not an option, both in help and in practice:
$ sudo gem install ibm_db --platform ruby
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --platform
UPDATE: The Ubuntu repos have 0.9.4 version of rubygems, which doesn't have the --platform option. It appears it may be a new feature in 0.9.5, but there is still no online documentation for it, and regardless, it won't work on Ubuntu which is the platform I need it to work on.
Versions of Rubygems from 1.0 and up automatically detect the platform you are running and thus do not ask that question. Are you able to update your gems to the latest?
$ sudo gem update --system
Be warned if you are on Windows once you have updated; you might run into this issue.
Another option is to download the .gem file and install it manually as such:
sudo gem install path/to/ibm_db-0.10.0.gem
This particular gem was at rubyforge.