IT関係のメモ

IT関係のメモを記録しておくブログ

Ubuntu 20.04 LTS で rubygems 3.1.4 への更新時にエラーになる

症状

rubygems を 3.1.4 に更新する際に以下のエラーが出る。

$ sudo gem update --system 3.1.4

(中略)

Loading the 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.

環境

解決方法

不明(あとで書く)。

2022/10/18追記:

Ubuntu 22.04 LTS にアップグレードしたところ解決した。

$ gem -v
3.3.5

なお、Ubuntu 22.04 LTSではRubyGemsがAPTでインストールされているので、gem update --system はサポートされないとのこと。

$ sudo gem update --system
ERROR:  Your RubyGems was installed trough APT, and upgrading it through RubyGems itself is unsupported. If you really need the latest version of RubyGems (tip: you usually don't), then you need to install RubyGems (and Ruby) manually, maybe using tools like ruby-install, rvm, etc.

備考

ちなみに、rbenvを使ってruby version 3.0.2 をインストールしてみたところ、rubygemsのバージョンは 3.2.22 になったが、sudo gem update --system で上記のエラーが出るのは変わらない。と思ったら、gem update --system は成功した。あれ?

参考