I have switched from rvm to asdf and need a behaviour similar to gemsets in rvm. I have two folders with the same project - one with the old version of it and one with the latest one. They have the same ruby version, but different versions of some of the gems. Is it possible in asdf to be on e.g. ruby 2.6 and run bundle on both projects without worrying about the conflicts?
-
Does it respect `.ruby-version` like RVM and `rbenv` do? – tadman Dec 12 '19 at 19:40
-
1"support for existing config files .node-version, .nvmrc, .ruby-version for easy migration" [link](https://asdf-vm.com/#/?id=why-use-asdf-vm) – sloneorzeszki Dec 13 '19 at 08:17
2 Answers
Remember that Gemfile
and Gemfile.lock
should make it possible to have multiple versions of the same gem installed and the correct one will be selected based on whatever constraints are described.
The only time you'll need to force a single version is when dealing with command-line tools (e.g. rails
or rake
) where only one can be active at any given time.
Gemsets are a byproduct of a time before Bundler and Gemfile
.

- 208,517
- 23
- 234
- 262
-
2You can invoke a specific verions of a gem with `gemname _1.0_`. For example `rails _5.2.1_ new blorgh` – max Dec 12 '19 at 20:12
-
-
@tadman Thanks. `The only time you'll need to force a single version` - can you please give an example of forcing (I thought you meant something like @max suggested, but it seems you didn't use that method before)? That's my main fear, with rvm I had kind of a sandbox with each gemset, right now I have multiple versions of the same gem coexisting in the same realm. If I have rails 4.2 and 5 in ruby 2.6 then I guess the latest one is used? – sloneorzeszki Dec 13 '19 at 09:00
-
It's generally the first one installed *unless* you allow subsequent installs to take over the command. As Max points out you can always run the specific version you need, or in the case of Rails, just use `bin/rails` in each install which will always engage correctly. – tadman Dec 13 '19 at 16:31
I have just encountered the same problem. And I solved the problem by adding the following lines in Gemfile.lock. Please pay attention though, sometimes two empty lines (without any spaces) need to be added before BUNDLED WITH section.
GEM
remote: https://rubygems.org/
specs:
BUNDLED WITH
1.17.3
After this is added to Gemfile.lock, you cd out of the rails project folder, and then cd back in, you can check bundler version has changed by asdf.
Hope this helps.