Ruby or rubygems update

Asked by Alexandr Evstigneev

Are there any plans on updating ruby to something more recent? Or rubygems at least?

Actual rubygems/bundler versions have important improvements/bugfixes, e.g. rubygems 3.2.3 introduced version checking while installing gem and there is no more dumb messages like `.... can't install gem version XXX, last compatble version is YYY, please try to install it.". Now rubygems does this by itself.

It is really painful and frustrating that i can't update rubygems for the shipped ruby, because it is forbidden by package maintainers.
Is somewhere a good explanation why this is being done?

Thank you for your work!

P.S. yes, i know about version managers and stuff, but there are reasons for using system ruby.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu ruby-defaults Edit question
Assignee:
No assignee Edit question
Solved by:
Alexandr Evstigneev
Solved:
Last query:
Last reply:
Revision history for this message
Alexandr Evstigneev (hurricup) said :
#1

The interesting thing, that I can update rubygems with simple `sudo gem update --system` on ubuntu 18.04 and 22.04 and can't on 20.04. This feels really strange.

Revision history for this message
Manfred Hampl (m-hampl) said :
#2

The rubygems package in Ubuntu jammy is version 3.3.5 and the one in kinetic is 3.3.15
see https://launchpad.net/ubuntu/+source/rubygems
Both numbers are higher than 3.2.3
Please note that there is no Ubuntu-provided version of rubygems in Ubuntu 20.04

Which Ubuntu release are you running, and from which source do you have ruby and rubygems installed?

What is the output of the commands

uname -a
lsb_release -crid
apt-cache policy ruby ruby-rubygems

Revision history for this message
Alexandr Evstigneev (hurricup) said :
#3

Linux AM-UNIT-0002 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal

ruby:
  Installed: 1:2.7+1
  Candidate: 1:2.7+1
  Version table:
 *** 1:2.7+1 500
        500 http://am.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status
N: Unable to locate package ruby-rubygems

Revision history for this message
Alexandr Evstigneev (hurricup) said :
#4

ruby from apt is shipped with rubygems 3.1.2 and it's not possible to upgrade it manually:

```
$ sudo gem update --system --no-document
Updating rubygems-update
Successfully installed rubygems-update-3.3.24
Installing RubyGems 3.3.24
Traceback (most recent call last):
 5: from setup.rb:22:in `<main>'
 4: from setup.rb:22:in `require'
 3: from /var/lib/gems/2.7.0/gems/rubygems-update-3.3.24/lib/rubygems.rb:1323:in `<top (required)>'
 2: from /var/lib/gems/2.7.0/gems/rubygems-update-3.3.24/lib/rubygems.rb:1323:in `require'
 1: from /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:49:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:50:in `<class:Specification>': undefined method `rubyforge_project=' for class `Gem::Specification' (NameError)
 3: from setup.rb:22:in `<main>'
 2: from setup.rb:22:in `require'
 1: from /var/lib/gems/2.7.0/gems/rubygems-update-3.3.24/lib/rubygems.rb:1319:in `<top (required)>'
/var/lib/gems/2.7.0/gems/rubygems-update-3.3.24/lib/rubygems.rb:1333:in `rescue in <top (required)>': undefined method `rubyforge_project=' for class `Gem::Specification' (NameError)
Loading the /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb file caused an error. This file is owned by your OS, not by rubygems upstream. Please find out which OS package this file belongs to and follow the guidelines from your OS to report the problem and ask for help.
```

Revision history for this message
Manfred Hampl (m-hampl) said :
#5

Manfred Hampl suggests this article as an answer to your question:
FAQ #3037: “no rolling release”.

Revision history for this message
Manfred Hampl (m-hampl) said :
#6

Do a release upgrade to Ubuntu 22.04 LTS and you will get a higher version of ruby and rubygems.

Revision history for this message
Alexandr Evstigneev (hurricup) said :
#7

Thanks, but my question was not "what to do", but are there plans to update (this one answered) and what is the reason behind locking manual upgrade for rubygems shipped with ruby package?

Revision history for this message
Manfred Hampl (m-hampl) said :
#8

"what is the reason behind locking manual upgrade for rubygems shipped with ruby package?"

see the FAQ linked above. Ubuntu is no rolling release, software is not updated no higher version in older Ubuntu releases.

If you want to have newer versions of ruby and rubygems on Ubuntu 20.04, then you have to install that software from some other source. The Ubuntu repositories do not offer that.

Revision history for this message
Alexandr Evstigneev (hurricup) said :
#9

Sorry, probably there is a problem with my English. I'm not asking why don't you update a package. I got it.

My question is: you are currently shipping ruby with particular version of rubygems. Shipped version of ruby is technically compatible with newer version of rubygems. But, when i'm trying to upgrade it with the gem tool, using gem update --system command, i'm getting an error:

Loading the /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb file caused an error. This file is owned by your OS, not by rubygems upstream. Please find out which OS package this file belongs to and follow the guidelines from your OS to report the problem and ask for help.

This was done by package maintainer intentionally. My question is - why?

Revision history for this message
Manfred Hampl (m-hampl) said :
#10

I am sorry, but I do not know the intentions of the package maintainer.

Googling for the error message brings (among others) https://github.com/rubygems/rubygems/issues/3831
Maybe that helps.

Revision history for this message
Alexandr Evstigneev (hurricup) said :
#11

Seems the issue is that operating_system.rb is behind the current rubygems.

Updating the monkeypatching from the same file from Ubuntu 22.04 fixes the problem.

Replacing in /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb

  if (RUBY_VERSION >= '2.1') && (RUBY_VERSION < '2.7')
    class << Gem::BasicSpecification
      alias upstream_default_specifications_dir default_specifications_dir
      def default_specifications_dir
        Gem.default_specifications_dir
      end
    end
  end

  if RUBY_VERSION >= '2.7'
    class Gem::Specification
      alias :upstream_rubyforge_project= :rubyforge_project=
      def rubyforge_project=(x)
      end
    end
  end

with

  class Gem::Specification
    begin
      alias :upstream_rubyforge_project= :rubyforge_project=
      def rubyforge_project=(x)
      end
    rescue NameError
      # rubyforge_project= was removed in RubyGems 3.1.4
      # If method rubyforge_project= is not present, that's ok
    end
  end

Revision history for this message
Alexandr Evstigneev (hurricup) said :
#12