4

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.

CripsyBurger
  • 361
  • 1
  • 3
  • 13
  • You're probably missing some build libraries. The answer will be found in the build log `/tmp/ruby-build.20220501122810.9309.log` from the error message. Please post the contents. – Casper May 01 '22 at 05:32
  • Hi @Casper. I have already made an edit to my question. I insert the link to redirect to the ruby log file. – CripsyBurger May 01 '22 at 05:51
  • Hmm. That doesn't look like the log file. It looks like the ruby-build command itself. Please double check that you are copying the same file that is listed in the error message when you run `rbenv install 2.6.6`. If that is indeed what is contained in the log file, then you need to file a bug report with rbenv, because in that case something went very wrong. – Casper May 01 '22 at 05:58
  • And also I try to install using rvm environment. rvm also gives some errors that ruby 2.6.6 cannot install. This is the error message. Error running '__rvm_make -j8', please read /home/tenish/.rvm/log/1651385294_ruby-2.6.6/make.log There has been an error while running make. Halting the installation. – CripsyBurger May 01 '22 at 06:09
  • You have to look at the log files. The errors should be in those. – Casper May 01 '22 at 06:54

2 Answers2

15

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

CripsyBurger
  • 361
  • 1
  • 3
  • 13
0

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.

kouroubel
  • 260
  • 4
  • 18