Skip to content

sudo gem update --system fails on fresh Ubuntu 18.04.5 LTS #4186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 5 tasks
pierre-pretorius opened this issue Dec 23, 2020 · 8 comments
Closed
2 of 5 tasks

sudo gem update --system fails on fresh Ubuntu 18.04.5 LTS #4186

pierre-pretorius opened this issue Dec 23, 2020 · 8 comments

Comments

@pierre-pretorius
Copy link

On a fresh new Ubuntu server 18.04.5 LTS system created from default AWS ami:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.5 LTS
Release:	18.04
Codename:	bionic
$ sudo apt-get install ruby2.5 ruby2.5-dev
...
$ sudo apt-get install bundler
...
$ sudo gem update --system
Updating rubygems-update
Successfully installed rubygems-update-3.2.3
Parsing documentation for rubygems-update-3.2.3
Done installing documentation for rubygems-update after 0 seconds
Parsing documentation for rubygems-update-3.2.3
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.2.3
Traceback (most recent call last):
	4: from setup.rb:23:in `<main>'
	3: from setup.rb:23:in `require'
	2: from /var/lib/gems/2.5.0/gems/rubygems-update-3.2.3/lib/rubygems.rb:1348:in `<top (required)>'
	1: from /var/lib/gems/2.5.0/gems/rubygems-update-3.2.3/lib/rubygems.rb:1348:in `require'
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:43:in `<top (required)>': uninitialized constant Gem::BasicSpecification (NameError)
$ gem list | grep bundler
bundler (2.2.3)

This issue is related to:

  • Network problems
  • Installing a library
  • Publishing a library
  • The command line gem
  • Other

Here are my current environment details:

$ gem env version
2.7.6

I also tried install rubygems-update-3.2.2 and rubygesm-update-3.2.1 and it gave the same error.

@deivid-rodriguez
Copy link
Member

Hello @pierre-pretorius!

Unfortunately, updating rubygems of a ruby installation provided by Debian is not supported. Debian packages provide custom code that they can change at any time and it's hard for us to make sure that everything they do works all the time. The custom code is that operating_system.rb file that's causing the error for you. In particular, they removed the reference to the missing constant that's causing the error in this commit, but that commit claims to drop support for ruby < 2.7, and your OS uses 2.5. So it sounds like upgrading the rubygems-integration debian package won't work for you.

There's also a DEBIAN_DISABLE_RUBYGEMS_INTEGRATION environment variable that they provide so that you can skip their custom code. But I have no idea how that will affect your usage of ruby & rubygems.

Why do you need to update rubygems?

@simi
Copy link
Member

simi commented Dec 23, 2020

We should probably move #3720 forward on this kind of Ruby distributions.

@pierre-pretorius You should use your system to update system Ruby/RubyGems/Bundler. Instead of doing gem update --system you should use apt to get supported Ruby version.

Alternatively you should install custom Ruby distribution and maintain it manually by gem.

You do mix both together and it doesn't work :/

@deivid-rodriguez
Copy link
Member

Yay! We also plan to add all this information to the error message you get when you do this, so that you don't need to open an issue to find out 😃. b

@deivid-rodriguez
Copy link
Member

. b

My cat 😆.

@YaEvan
Copy link

YaEvan commented Dec 29, 2020

On a fresh new Ubuntu server 18.04.5 LTS system created from default AWS ami:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.5 LTS
Release:	18.04
Codename:	bionic
$ sudo apt-get install ruby2.5 ruby2.5-dev
...
$ sudo apt-get install bundler
...
$ sudo gem update --system
Updating rubygems-update
Successfully installed rubygems-update-3.2.3
Parsing documentation for rubygems-update-3.2.3
Done installing documentation for rubygems-update after 0 seconds
Parsing documentation for rubygems-update-3.2.3
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.2.3
Traceback (most recent call last):
	4: from setup.rb:23:in `<main>'
	3: from setup.rb:23:in `require'
	2: from /var/lib/gems/2.5.0/gems/rubygems-update-3.2.3/lib/rubygems.rb:1348:in `<top (required)>'
	1: from /var/lib/gems/2.5.0/gems/rubygems-update-3.2.3/lib/rubygems.rb:1348:in `require'
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:43:in `<top (required)>': uninitialized constant Gem::BasicSpecification (NameError)
$ gem list | grep bundler
bundler (2.2.3)

This issue is related to:

* [ ]  Network problems

* [x]  Installing a library

* [ ]  Publishing a library

* [x]  The command line `gem`

* [ ]  Other

Here are my current environment details:

$ gem env version
2.7.6

I also tried install rubygems-update-3.2.2 and rubygesm-update-3.2.1 and it gave the same error.

If you install ruby by apt install ruby2.5 ruby2.5-dev, only exec gem install bundler, then print gem list gem list, the bundler now is bundler2.

@pierre-pretorius
Copy link
Author

Thank you for the quick response and detailed explanation of the issue.

Why do you need to update rubygems?

Our server provisioning is automated and follows a process that usually completes without issues, but this time it ran into the error below where the suggested solution was to update system gems:

https://bundler.io/blog/2019/05/14/solutions-for-cant-find-gem-bundler-with-executable-bundle.html

Our current solution is to install bundler 1 via sudo gem install ... and then uninstall bundler 2 via sudo gem uninstall .... Not ideal but our Gemfile.lock is still on bundler 1 so no issues there. In the medium term we will switch to Ubuntu 20.04 with Ruby 2.7 which should avoid this issue.

@deivid-rodriguez
Copy link
Member

Oh, I see! That post should clarify that if it is an OS installation, gem update --system is not supported, so the solution is to do what you did there and install bundler 1.

In any case, rubygems is still picky when choosing the bundler version if the "BUNDLED WITH" version and the running version are different major versions of bundler, so gem update --system wouldn't have helped there.

I'll edit that blog post to try to make it more useful.

@deivid-rodriguez
Copy link
Member

I proposed an update to the blog post that's causing this constant flow of upcoming bug reports: rubygems/bundler-site#547.

I also plan to make a proposal to deprecate operating_system.rb in favor of coordinating with OS-packagers to provide everything they need through configuration so that they don't need to add any ruby code on top of rubygems.

For the rest I'll close this ticket since there's not much else we can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants