jonathanmorley / asdf-bundler

Apache License 2.0
7 stars 4 forks source link

This plugin does not do anything if a version of asdf Ruby >= 2.6.0 is also installed #6

Open Taytay opened 2 years ago

Taytay commented 2 years ago

I don't think this needs to be "fixed" per se, but we were trying to use this plugin to enforce our version of bundler the same way we enforced other local tool versions with asdf. However, we also currently use Ruby 2.7.5 in asdf, and of course that already includes a version of Bundler/bundle. After installing this plugin and defining a different version of Bundler, it does not take effect because the bundle command is still being run from the currently installed ruby folder. asdf exec "bundle" --version just runs the bundle command from inside of the currently installed Ruby.

I came to this issues list and didn't see anyone else reporting the issue, but after reading https://github.com/jonathanmorley/asdf-bundler/issues/2, I'm beginning to think that we are swimming upstream and should enforce/install our bundler version another way.

odinhb commented 2 years ago

I ran into the same-ish problem. Maybe the information in #2 should be surfaced in the README for this project?

odinhb commented 2 years ago

To clarify my previous comment, I ran into the "same problem" in that it seems this plugin is intended mostly for older ruby versions, but I tried using it with a ruby version that would ship bundler by default.

But as to your assertion that this doesn't do anything, I have to note that I'm very much experiencing that it switches bundler versions correctly:

$ cat .ruby-version
2.7.5
$ cat .tool-versions
yarn 1.22.17
bundler 2.3.5
$ bundle --version
Bundler version 2.3.5
$ asdf local bundler 2.3.11
$ bundle --version
Bundler version 2.3.11

Maybe it works better with newer versions of bundler?

odinhb commented 2 years ago

This appears to happen because I installed asdf-bundler before asdf-ruby.

So this will use the ruby-provided bundler: (these examples assume a clean environment, you can asdf plugin remove ruby && asdf plugin remove bundler to try them.)

$ cat .tool-versions
bundler 2.3.5
ruby 2.7.5
$ asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
$ asdf plugin add bundler https://github.com/jonathanmorley/asdf-bundler.git
$ asdf install
<... snip ruby compile output>
$ ruby --version
ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
$ bundle --version
Bundler version 2.1.4

While this will use asdf-bundler-provided bundler:

$ cat .tool-versions
bundler 2.3.5
ruby 2.7.5
$ asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
$ asdf plugin add bundler https://github.com/jonathanmorley/asdf-bundler.git
$ asdf install bundler
$ asdf install
<... snip ruby compile output>
$ ruby --version
ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
$ bundle --version
Bundler version 2.3.5
eprothro commented 2 years ago

@odinhb This plugin installation re-ordering worked for me. Do we have an idea of why this is the case, and what we can do to get asdf bundler working reliably?

odinhb commented 2 years ago

I don't know, I haven't been able to locate the problem.

Maybe asdf-ruby could be aware of the asdf-bundler plugin when running install, so that it doesn't include the bundler version that is shipped with ruby.

Alternatively, maybe asdf itself could allow us to fix it, by allowing asdf-bundler to declare its collision with asdf-ruby (that they will both provide the same binary), such that asdf knows always to use the asdf-bundler provided binary over the ruby one, unless there is no bundler version specified in .tool-versions.