I currently have 2 ruby versions, 2.5.5 and 2.3.8, I am managing them with rbenv, and for gems, I use bundler to manage my specific gem versions. I have an issue when I want to switch to a project that uses 2.3.8 or a version that has to do with Ruby version 2.3.
My question is how do I get bundler to run the command to bundle install interact with my 2.3 projects.
My current version of bundler is 2.0.2.
I have already tried installing a lower version of bundler of which the bundler website claims to interact with ruby version 2.3.
I thought that if I specified the command to run bundle _version_ install it would work, but it still gave me the response that it needed ruby version 2.5 for bundler to work.
Lots of help appreciated.
In some situations, isolation can help. I would like to recommend rvm (https://github.com/rvm/rvm) for managing ruby versions. This tool is very similar to rbenv but in comparison, it allows you to create gemsets which are kind of containers of gems for special purposes. For instance:
rvm install 2.5.5 --disable-binary
rvm use 2.5.5#name-of-gemset --create
gem install bundler
bundle install # inside your project folder with Gemfile
I think that you will not have problems with versions again.
Related
I'm using rbenv, ruby 2.6.5, and attempting to use bundler 2.0.2. Currently when I run gem list, bundler 2.0.2 is the only version shown on the screen. However, when I run bundle install in my project, an error is thrown stating that my current bundler version is 2.1.2. If I run bundler version in the shell, it indeed says 2.1.2. Where can I find this version and eliminate it?
Thanks,
Ed
Uninstall all versions of bundler with gem uninstall bundler and install the version you need again.
What's the best way to upgrade to Ruby 2.3 through rvm while keeping all your gems installed on previous version (e.g. json, nokogiri, etc)?
EDIT
This question has an answer here: RVM: How to use gems from a different ruby?
$ rvm gemset copy $oldversion 2.3.0 ## Assign or replace $oldversion with old version name
ORIGINAL
Before installing Ruby 2.3, get a list of your installed gems and their versions using gem list. Then, after you install Ruby 2.3, use rvm to set 2.3 as the new default:
$ rvm install 2.3.0
$ rvm --default use 2.3.0
If you use Bundler, gem install bundler and then bundle install in all your project directories. This should install all of the gems relevant to your work.
If you don't use Bundler, or if you have gems installed that aren't part of any project's Gemfile, then you will want to go through the list of gems and their versions that you made earlier and gem install each of them, using -v to specify the version.
I'm working on a project and we've just updated bundler to version 1.7.0. There was a few days of trouble in getting all the gemfiles/gemfile.locks in a correct state, but I'm still having trouble with one issue in particular.
If there are differences in Gemfile.lock, I check it out, and then bundle so that I will have the gems in the Gemfile. However bundle seems to always auto-upgrade my gems. For example:
Installing multi_json 1.10.1 (was 1.9.2)
The rest of my team is using 1.9.2 - there's a dependency in another part of the application or...who knows. I should be using 1.9.2, but bundler consistently 'auto-upgrades' everytime i run bundle. Is there a way to prevent this behavior? I'm using RVM 1.25.23
Bundler 1.7.0 has some bugs which can result in unexpected gem updates. Please try upgrading to the latest version (1.7.2 at the time that I write this).
See:
https://github.com/bundler/bundler/issues/3136
https://github.com/bundler/bundler/issues/3142
https://github.com/bundler/bundler/issues/3149
Try:
bundle install --frozen
This should prevent bundler to update the Gemfile.lock.
I recently upgraded to Mac OS 10.9 and now I get this message when I run boxen:
Bundler is not compatible with Ruby 2.0 or Rubygems 2.0. Please
upgrade to Bundler 1.3 or higher. Can't bootstrap, dependencies are
outdated
I imagined that I could just set boxen's .ruby-version file to something like 1.8.7, but based on the message above, it still seems to be using Ruby 2.0.
How can I run boxen in Mavericks?
I ran into the exact same issue. The answer is actually deceptively simple. Since Mavericks now includes Ruby 2.0.0p247 and Rubygems 2.0.3, and you apparently upgraded, your system ruby will not find your bundler or ansi gems. So what you need to do is install both with your system ruby, as root.
sudo /usr/bin/gem install bundler
sudo /usr/bin/gem install ansi
Then just restart or terminal. You can now run boxen as you would normally. Also, in order not to keep old files lying around, you may want to cleanup /Library/Ruby/Gems/1.8/ because it will include your old installation of both bundler and ansi on a ruby and gem installation you no longer have.
Seems the problem is with bundler. Just try to update it.
gem install bundler
system ruby (now 2.0) needed an updated version of bundler. Currently, only a pre-release version is compatible with Mac OS 10.9. If gem install bundler complains that you need a newer version of Bundler, as above, try gem install bundler --pre. Also, you may need elevated privileges to install gems for your system's ruby.
I am still confused about why Boxen wants to use system ruby's bundler gem when a different ruby installation is defined by Boxen's rbenv config, but the problem has a working solution now.
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).