Home > database >  Cannot install ruby version 2.6.6 on Ubuntu 20.04
Cannot install ruby version 2.6.6 on Ubuntu 20.04

Time:05-03

I have an existing project which is using ruby version 2.6.6. But my machine ruby version is 3.0.2. So when I try to run my project on my machine it shows this error.

Your Ruby version is 3.0.2, but your Gemfile specified 2.6.6

So I also try to install ruby 2.6.6 using rbenv envirourment

rbenv install 2.6.6
Installing ruby-2.6.6...

BUILD FAILED (Ubuntu 22.04 using ruby-build 20220426)

Inspect or clean up the working tree at /tmp/ruby-build.20220501122810.9309.e7yCPU
Results logged to /tmp/ruby-build.20220501122810.9309.log

Last 10 log lines:
installing default date_core libraries
linking shared-object fiddle.so
make[2]: Leaving directory '/tmp/ruby-build.20220501122810.9309.e7yCPU/ruby-2.6.6/ext/readline'
make[2]: Leaving directory '/tmp/ruby-build.20220501122810.9309.e7yCPU/ruby-2.6.6/ext/fiddle'
linking shared-object bigdecimal.so
make[2]: Leaving directory '/tmp/ruby-build.20220501122810.9309.e7yCPU/ruby-2.6.6/ext/bigdecimal'
linking shared-object date_core.so
make[2]: Leaving directory '/tmp/ruby-build.20220501122810.9309.e7yCPU/ruby-2.6.6/ext/date'
make[1]: Leaving directory '/tmp/ruby-build.20220501122810.9309.e7yCPU/ruby-2.6.6'
make: *** [uncommon.mk:286: build-ext] Error 2

So I not sure how to make it work. Anybody can help with this. I try all the possible way from the internet but it doesnt work.

ruby -v

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]

Rails -v

Rails 6.1.4.1

Rbenv --version

rbenv 1.1.2

Ruby-build log file link here.

CodePudding user response:

You can have both versions of ruby installed with rvm. See https://rvm.io/rubies/default

Now the trick here for the correct ruby version to be picked automatically (so you don't do have to call rvm use 2.6.6 everytime) is you don't open a terminal directly to the project with the old ruby version. Instead, you open a terminal to it's parent directory and cd into the project's folder before you start the server.

I used to have the same problem and this is how I resolved it.

CodePudding user response:

After few day I found out that the error causes because of OpenSSL for ubuntu

After I execute this commands I can download the ruby 2.6.6

rvm pkg install openssl

next

rvm install ruby-2.6.6 --with-openssl-dir=$HOME/.rvm/usr

You can refer to the discussion here

  • Related