Search code examples
rubyjekyllubuntu-16.04rbenv

Why is gem telling me the current ruby version is 2.5.0 when it's not?


Context: I'm trying to install jekyll on Ubuntu 18.04 LTS so that I can work on a GitHub Pages site without having to deploy my changes to production every time I want to view them.

Here's the situation. When I run sudo gem install jekyll, it tells me to install google-protobuf. When I run sudo gem install google-protobuf, it tells me:

google-protobuf requires Ruby version < 3.3.dev, >= 2.6. The current ruby version is 2.5.0.

Running rbenv versions shows me that there are two versions on my system

system

* 3.2.2 (set by /home/me/.rbenv/version)

I think system is the 2.5.0 version causing the problem, but running ruby -v outputs

ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]

and running rbenv global outputs

3.2.2

so it makes no sense to me that the system is still using 2.5.0. Can someone shed some light on what the fix is?


Solution

  • Not knowing rbenv (but rvm, asdf and other similar tools), but as a Ruby Version manager, its job is to set up different/multiple Ruby environments with different gems installed for different users.

    Since you call sudo gem install ... this will likely resolve to the global gem command available by default for a user with heightened priviliges (a super user). Most probably rbenv is not set up for this case, so that it falls back to the system-wide install ruby and gem commands, which seems to be Ruby 2.5 on Ubuntu 18.04.

    Thus, try to run the command without sudo. If this fails, because it wants to install system-wide packages (libraries) resort to the rbenv documentation how to achieve this. It might give a list of commands to run (e.g. sudo apt install libprotobuf) or ask you for a password to do system modifications.