unable to upgrade to ruby 3.1.2 - ruby-on-rails

I am trying to upgrade ruby version 3.1.2 I am getting this error and when it says to install messing dependencies I get the error unable to locate the package now my ruby version is 2.7.4 and I installed using rbenv, and I use Ubuntu 21.10

Related

Cannot install rails version 4.2.5 on Ubuntu in WSL when I have ruby 2.2.1 active. nokogiri requires Ruby version >= 2.3.0

Trying to install rails version 4.2.5 on Ubuntu in Windows Subsystem for Linux on Windows 10 when I have ruby 2.2.1 installed and active I get the following error:
~$ gem install rails -v 4.2.5
ERROR: Error installing rails:
nokogiri requires Ruby version >= 2.3.0.
I need these versions to collaborate on a project which uses these versions.
I started by installing WSL (1 not 2) on windows 10, then downloaded and installed Ubuntu Linux. Then I installed rbenv, updated dependencies, installed ruby 2.5.1 which was fairly easy.
I had problems installing ruby 2.2.1 but got there after doing
$ sudo apt-get install -y libssl1.0-dev
to install an earlier version of libssl which ruby 2.2.1 needs.
I installed node.js and an earlier version of bundler using
$ gem install bundler -v 1.17.3
as trying
$ gem install bundler
failed with a similar error.
(I also installed ruby 2.5.1 and rails 4.2.5 on top of it with few problems)
Trying various diagnostics showed rails was not installed for ruby 2.2.1
~$ rails
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.5.1
(but not in ruby 2.2.1, which is where I need it)
Looking at my files in windows File Explorer (only looking) I can see that while my ruby 2.5.1 gems include rails my ruby 2.2.1 files are incomplete and do not include rails.
I think the PATH is correct.
$ echo $PATH returns
/home/johnloughran/.rbenv/plugins/ruby- build/bin:/home/johnloughran/.rbenv/shims:/home/johnloughran/.rbenv/bin:/usr/
local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local
/games:/mnt/c/Program
Files/WindowsApps/CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2019.522.0_
x64__79rhkp1fndgsc: ........ :/snap/bin
I modified my .bashrc file to add various entries to the PATH which have been included above.
I repeated the whole process twice starting from scratch (uninstalling Ubuntu) with the same block at the end.
What is my best option here to try and continue?
Thanks Josien for your comments. In the first case my collaborators have these versions of Ruby and Rails working together, but its a few years now since they installed them. One, David, helped me by trying a fresh install of rails 4.2.5 on ruby 2.2.1 which ran into the same problem above with nokogiri.
He solved it by installing a lower version of nokogiri in a new test directory, which I repeated as:
test$ gem install nokogiri -v 1.9.1
This worked. Then I installed rails as
test$ gem install rails --version 4.2.5
At last .... it worked!!!! :-)
To prove it I was able to get rails to return its version correctly.
test$ rails -v
Rails 4.2.5
Then I was able to create an app as
<working-directory>$ rails new learn-ruby
which works, almost, having hit another dependency problem, but hey ... that's programming!
Re your second comment I do not know enough about this stuff to know how relevant it is that this version of ruby is deprecated and the rails version is getting there too.

Upgrade Ruby version while deploying to EB

I have a production rails application on Ruby 2.2.5 but I updated my app to ruby 2.5.3 and rails from 4.2 to 5.2. When I try to deploy this to ElasticBeanstalk I get the following errors everytime:
Warning: the running version of Bundler is older than the version that created the lockfile.
We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Your Ruby version is 2.2.5, but your Gemfile specified 2.5.3.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
To fix this I ssh'd into the instance and installed rvm before updating the ruby version using
rvm --default use 2.5.3
After this I updated my bundler as suggested in the error message but it seems like the ruby version gets reset to 2.2.5 everytime I close my connection and ssh in again because doing
ruby -v gives 2.2.5
How can I update the ruby version on my instance?
Elastic Beanstalk sets the Ruby version in the Platform (you can think of this as the base AMI). To upgrade this you'll need to update your platform version.
Depending on the web server you use, it sounds like you'll need one of:
64bit Amazon Linux 2018.03 v2.8.7 running Ruby 2.5 (Puma)
64bit Amazon Linux 2018.03 v2.8.7 running Ruby 2.5 (Passenger Standalone)

Ruby 1.8.7 is not installing through RVM

I am trying to install ruby version 1.8.7 through Rvm, but can't installed this version and getting following error
Error running '__rvm_make -j4',

ERROR: Error installing rails on ubuntu

I'm getting the following error:
ERROR: Error installing rails:
mime-types-data requires Ruby version >= 2.0.
This happens while installing Rails on Ubuntu using the command:
sudo gem install rails
How can I fix this?
As the error suggests, you need Ruby version 2.0 or later.
You are probably using system ruby. Not sure about Ubuntu 16, but earlier versions used to come with Ruby v1.9.3. You can check your current Ruby version by running the following code in your terminal:
ruby -v
For easier rubies version management, I would highly suggest to use one of the popular ruby version managers:
RVM
rbenv
Install rvm and then install latest stable version.
# Using rvm
rvm install 2.3
# Using rbenv
rbenv install 2.3
The current ruby version in your system is below 2.0.
Try installing ruby 2.0 or higher versions before installing rails.
That will solve the problem.
I was facing the same problem trying to install rails with sudo.
I was getting: ERROR: Error installing mime-types-data: mime-types-data requires Ruby version >= 2.0
The thing is ruby -v gives me ruby 2.2.3p173 while sudo ruby -v gives me ruby 1.9.3p484.
So instead of sudo gem install rails I just did gem install rails and it worked.
Error: mime-types-data requires Ruby version >= 2.0
Notice: You shouldn't install rails with sudo permission.

How to compile Ruby with Readline support?

I'm running Linux Mint 15 which is based on Ubuntu 13.10. I installed Ruby with RVM. I'm trying to run Rails and I get the following error:
You're running a version of ruby with no Readline support
Please `gem install rb-readline` or recompile ruby --with-readline.
I tried every suggestion I found here on SO regarding this problem but I still get this error when trying to run rails server. The suggested website for the fix http://beginrescueend.com/packages/readline/ is unavailable.
For macOS: https://github.com/guard/guard/wiki/Add-Readline-support-to-Ruby-on-Mac-OS-X
RUBY_CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 2.3.1
This was answered here for ubuntu/rvm combination: How to get Readline support in IRB using RVM on Ubuntu 11.10
I use chruby/ruby-build for the task, with ruby-build it can be done just like that(you can install it even to rvm folder):
export RUBY_CONFIGURE_OPTS=--with-readline-dir=/your/readline/headers/path
ruby-build 2.0.0 ~/.rvm/rubies/

Resources