Trying to Match Old Ruby and Rails installation - ruby-on-rails

Ubuntu 22.04
I was able to install rails 1.9.2 rbenv but I can't match a rails version to it.
On the old server
rails -v returns:
The program 'rails' can be found in the following packages:
ruby-railties-3.2
ruby-railties-4.0
When I go to install Rails gem install rails
I get...
ERROR: Error installing rails:
concurrent-ruby requires Ruby version >= 2.2.

I do not know why you need to run such an old version of Ruby, but I guess there are reasons.
gem install rails will just try to install the latest version of Ruby on Rails that obviously is not compatible with such ancient version of Ruby as 1.9.2.
There are pages that list the compatibility between certain Ruby and Ruby on Rails versions, for example, this or this. When looking at those tables, I guess the best choice seems to be Ruby on Rails 3.2.x. To install the latest 3.2.x version of Rails use this command:
gem install rails -v 3.2.22.5
Running such ancient Ruby and Ruby on Rails will lead to endless problems. Foremost, there are likely unfixed security vulnerabilities in those old versions. But finding good documentation, compatible gems and support in general will be hard too.
I guess from your question that you inherited an old project without much documentation and – most importantly – without a Gemfile. Therefore, I suggest adding bundler and a proper Gemfile. You will need to figure out all your app's dependencies to install the application anyway, better document those dependencies with bundler right from the start. This examples might help.

Related

Do I have to install Ruby from source to get Ruby 2.2.0 and Rails 4.2.0 installed on my windows machine?

I currently have Ruby 2.2.6 and Rails 5.0.1 installed on my Windows 10 machine. I have cloned an existing project that has the following settings included in its Gemfile:
# Lock-in Lang and Framework:
ruby '2.2.0'
gem 'rails', '4.2.0'
I'm having a surprisingly hard time figuring out how to get Ruby 2.2.0 and Rails 4.2.0 installed. Ruby has good documentation of different installation options, but I think I've exhausted the Windows options without any success. Here are a couple I tried:
Installers: I couldn't find an option for downloading either from RailsInstaller, RubyInstaller, and Bitnami.
RVM: I tried (unsuccessfully) following this blog post to install cygwin so that I could use RVM, but then saw in the comments that the author now recommends spinning up a linux VM rather that using this method.
Pik and Uru: It appears Pik is no longer maintained, and I couldn't figure how to download new versions and ruby and rails with Uru as opposed to managing already downloaded versions.
EDIT: I also tried simply changing the version numbers for ruby and rails in the Gemfile to 2.2.6 and 5.0.1. When I do this I (very understandably) get a message when I try to use a rails command saying I need to run bundle update rails. When I run that rails update I get the following error: Bundler could not find compatible versions for gem "rack". I've done some googling on that option, and it looks like resolving that issue might be possible but requires some more involved tinkering with my Gemfile configuration.
I think my next option is to install Ruby from the source, but I wanted to throw a question up here first to make sure I'm not missing an easier method. So my question is - is it really this hard to get an older minor release of ruby and rails installed on Windows? I realize that the majority of users are probably looking for the most recent release, but it doesn't seem to me that my use case is terribly unique.
The oldest available Ruby 2.2.x via RubyInstaller is 2.2.1
So, the answer to your question is, "Yes, you'll have to build from source."
But then again,
v2.x of gem "rack" requires at least Ruby v2.2.2
And depending on what other gems are included in your Gemfile, you'll still have to reconfigure your Gemfile to get this app running.
So the best solution is probably to use the latest patch version of Ruby 2.2.x and lock rails to 4.2.x. (The app may not be compatible with Rails 5.x)
# Lock-in Lang and Framework:
ruby '2.2.6'
gem 'rails', '~> 4.2'
Then run bundle install to install all the gems required by the Gemfile

I am having trouble uninstalling Rails 4.1.5 and installing Rails 4.0.8

I tried uninstalling Rails 4.1.5 by doing "gem uninstall rails" and then installing Rails 4.0.8 by doing "gem install rails --version 4.0.8". However, now when I try to see what version of Rails I am using by doing "rails -v" I still get "Rails 4.1.5". How do I fix this?
I know I'm a bit late however I am answering in case others need an answer of how to manage gem versions. The linked duplicate question offers a perfectly fine answer to the question but does not give guidance to how to easily manage this long term. I do the following before starting every new project.
First you need rvm to manage ruby versions and create gemsets. With gemsets you can create isolated groups of gems that are project or ruby or rails version specific (it's up to you how you organize yourself).
After installing a version of ruby to use you create a gemset and tell your system to use this version of ruby with this gemset.
Then select the gemset and install the version of rails you want to use into the gemset. You will also need to install bundler into the gemset.
Once you have this setup you can insert the following lines into your rails gem file to tell this project which ruby version, rails version and gemset to use (in my example I am using ruby version 2.1.5 with the gemset named scan and the rails version 4.0.8)
ruby '2.1.5'
#ruby-gemset=scan
gem 'rails', '4.0.8'
Then cd into the rails project directory and run bundle install. Bundler will install the gems from your project's gem file into the selected gemset. Now you have an isolated and stable system for the project. If you have another project with different ruby version, rails version and gemset any changes there will not affect anything here.
For more details on how to setup rvm just go to the website and read the documentation. It's really easy to use and will save you many headaches.

How do I upgrade the Ruby version of my project?

I recently started learning Rails using Ruby 1.9.3p385, and I'm trying to develop a small project with it.
I'm using Linux so I installed Ruby using RVM.
I developed a few pages, following some tutorials. I would like to upgrade my project to use Ruby 2.0.0. What do I have to do?
I installed Ruby 2.0.0 with RVM:
rvm install 2.0.0
Everything seems OK, so I tried to use it:
rvm use 2.0.0-p247
But when I try to run my Rails server using rails server, I get the following message:
bash: rails : command not found
I've read the RVM documentation about upgrading Ruby but I don't really understand what it does; I'm afraid of breaking everything.
Does it will upgrade my project in a way it will use Ruby 2.0.0 or what should I do?
Next, I will want to upgrade also to Rails v4.
Your gemset which comes with new Ruby version is empty. Try this:
gem install bundler # this will install bundler
bundle # this will use bundler to install required gems
rails server
Did you run rvm use 2.0.0-p247 or did you use rvm use 2.0.0-p247 --default? The later will set Ruby v.2.0 as the default for your system. Failure to do that will revert your Ruby to whatever RVM's default is the next time you log into your system or open a new terminal window.
When RVM installs a new version of Ruby, it installs only the default gems. It CAN upgrade a Ruby to another version, and optionally install the existing gems as it does so, but that's not what you asked it to do: rvm install 2.0.0 only installs Ruby. At that point you have to install the other gems you need, which would include Rails.
My general practice when installing various versions of Ruby and the gems I like is to use two command-line pipes to dump my existing gems, then (re)install them. First I switch to an existing Ruby whose gems I want to duplicate, then run:
gem list | cut -f1 -d' ' > ~/gem_list
Then I switch to the newly installed one, and run this:
xargs gem install < ~/gem_list
This does a completely clean install of the gems, outside of RVM's commands.
Why? Habit. Paranoia based on some "experiences" I had in the past with RVM.
Once that's all done and I have brand-spanking-new Ruby and gems, I'll proceed with running bundler or other housekeeping chores.
when you install a new ruby version, you have to reinstall all the gems for that version. start of by installing bundler first. Then run bundle in your rails root directory. When you encounter no errors, you're good to start the rails server. Good luck!
run bundle install on the application root, you need to reinstall all your dependencies for the new version of Ruby.

(MacOSx) Earlier version Rails2.3.8, i installed Rails3.2.0 but i still not able to access new version of Rails. Please help me fix it

Parsing documentation for bundler-1.3.2
Installing ri documentation for bundler-1.3.2
Parsing documentation for rails-3.2.12
Installing ri documentation for rails-3.2.12
Done installing documentation for i18n, multi_json, activesupport, builder, activemodel, rack, rack-cache, rack-test, journey, hike, tilt, sprockets, erubis, actionpack, arel, tzinfo, activerecord, activeresource, mime-types, polyglot, treetop, mail, actionmailer, rack-ssl, thor, rdoc, railties, bundler, rails (58 sec).
29 gems installed
204-252:~ narendra$ rails -v
Rails 2.3.8
204-252:~ narendra$ gem update rails
Updating installed gems**strong text**
Nothing to update
If you're using rbenv you can try running rbenv rehash after updating rails.
If you're in a rails project folder that was built with Rails 2.3.8 then when you run rails -v in that folder it will return that version of rails instead of the latest one. So you could try moving to another folder and see if running rails -v gives you the version you're expecting.
Also, if you installed rails with sudo gem install rails sometimes /usr/bin/rails still points to the old version, so you could update that to point to the new one.
Since rails 3.2.12 is not included in the output of gem list, I suspect you installed the gem with sudo. Installing with sudo and then trying to list the gems without it (or other operations) can give you a different list. Try doing sudo gem list, and if rails 3.2.12 is in there, thats your problem. Try installing it without sudo.

updating rails previous project to current version

i have a project of rails with versions ruby 1.8.7, gems 1.3.6, rails 2.3.5
I want to update the project to the current version can you guys please give the picture how to update older rails applications to current version....
thank you..
RVM and Bundler with the use of a gemfile is helpful in the situation you are in.
RUBY Versioning
Install Ruby Version Manager (pay careful instructions to how to install)
Installation documentation for RVM is here https://rvm.io/rvm/install/
once installed download the version of RUBY you want to use
rvm install 1.9.3 or rvm install 1.8.7
afterwards type in RVM use 1.8.7 and it will set your system to use the older version
Gem Versioning
Apparently you can install the gems in rails 2 by using the rake command
enter in rake gems:install
Your code to config gems are located in the config/environment.rb
There is a helpful tool called "Bundler" which is a gem that easily lets you manage your gem version through the use of a file called a "gemfile". I think the link below is a good resource on how to upgrade your Rails 2 project
http://llamarada-cinetica.heroku.com/blog/2011/02/14/using-gemfiles-on-rails
with RVM and gem configuration you can upgrade gems as needed and check if it works with your build.
(others please correct me if i'm wrong I've only been on rails for a short while)
My suggestion is If your client want you to update the project you can update else extend the application features with older version of Rails because lots of features will break if you upgrade to new Rails version.
And your question is not suitable to ask in Stackoverflow.

Resources