ruby / snap.ruby

Ruby snap
29 stars 5 forks source link

bundler downgrade from 2.5 to 2.6 #12

Closed wlipa closed 3 years ago

wlipa commented 5 years ago

The version of bundler in the 2.6 channel is 1.x, but the version of bundler in the 2.5 channel is 2.x. It's surprising that upgrading a major version of ruby would downgrade a major version of bundler.

$ sudo snap install ruby --classic --channel=2.5/stable
ruby (2.5/stable) 2.5.5 from Ruby core team (rubylang✓) installed
$ ruby --version
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
$ gem --version
2.7.6.2
$ bundle --version
Bundler version 2.0.1

$ sudo snap install ruby --classic --channel=2.6/stable
ruby (2.6/stable) 2.6.2 from Ruby core team (rubylang✓) installed
$ ruby --version
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
$ gem --version
3.0.3
$ bundle --version
Bundler version 1.17.2

(I'm not sure if this is due to the snap packaging or not, though.)

wlipa commented 5 years ago

In the 2.6 snap, there's a 1.17.2 bundler at 2.6.0/bundler and a 2.0.1 bundler at gems/2.6.0/gems/bundler-2.0.1.

$ grep -m1  VERSION /snap/ruby/132/lib/ruby/2.6.0/bundler/version.rb
  VERSION = "1.17.2" unless defined?(::Bundler::VERSION)

$ grep -m1 VERSION /snap/ruby/132/lib/ruby/gems/2.6.0/gems/bundler-2.0.1/lib/bundler/version.rb
  VERSION = "2.0.1" unless defined?(::Bundler::VERSION)
wlipa commented 5 years ago

Installing bundler 2.0.1 as a user does not seem to work. Is there a way to get bundler 2.0.1 working with the 2.6 snap? (This is with the default gem env.)

$ gem install bundler
Fetching bundler-2.0.1.gem
Successfully installed bundler-2.0.1

$ ~/.gem/bin/bundle --version
Bundler version 1.17.2
mattbrictson commented 5 years ago

It looks like the ruby snap works by setting the RUBYLIB environment variable in order to ensure that /snap/ruby/132/lib/ruby/2.6.0 is included in the ruby load path:

https://github.com/ruby/snap.ruby/blob/427a8a826b84005353c55015f5cdd5cbb7361d04/snap/snapcraft.yaml#L14

RUBYLIB always comes first in the load path, before any gems. That means that the version of bundler that comes with Ruby 2.6 (i.e. /snap/ruby/132/lib/ruby/2.6.0/bundler.rb) will always take precedence over any version that is installed via rubygems.

I don't see a way to solve this unless the snap can somehow be packaged without relying on RUBYLIB, or unless bundler is removed from ruby's standard library.

wlipa commented 5 years ago

I wouldn't necessarily mind using ruby's included bundler / rubygems if they were kept up to date. To be honest, I find the current relationship between ruby, rubygems, and bundler to be rather baffling.

hsbt commented 3 years ago

After Ruby 2.6, Ruby bandled bundler as stdlib. I relied on its default version.