Rails and Ubuntu reporting different ruby versions - ruby-on-rails

I use Vagrant and Chef to create new servers when I am developing. I want to start out on Ruby on Rails so I am setting up a server. Everything is working but Ubuntu and Rails are reporting different Ruby versions.
Ubuntu 12.04: ruby -v = ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
Rails = 1.8.7 (x86_64-linux)
I don't want Ruby 1.8.7 on the system at all but I can't get rid of it. Is there anyway to set a default Ruby version?
I don't want top use RVM or similar.

try this aptitude purge ruby
and then install the latest version or the version you want
came across this post in stackoverflow
How do I make Ruby 1.9 the default Ruby on Ubuntu?

This did the trick.
https://github.com/royratcliffe/VagrantBaseBoxes

Related

Project selected ruby version does not match ruby -v using asdf-ruby

I switched to a new computer and set up a whole development environment from start. One of the changes was trying to use asdf instead of rvm. Sadly when trying to run rails s or rails c on one of the projects I have im running into:
Your Ruby version is 2.7.1, but your Gemfile specified 2.6.3
2.6.3 is the version specified by Gemfile indeed, the same is in .tool-versions file and .ruby-version.
My lack of understanding comes from me not having ruby 2.7.1.
asdf list =>
ruby
2.6.3
ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
which ruby
/home/kkp/.asdf/shims/ruby
Any help would be appreciated.
Just as I posted I suddenly remembered to run
gem install bundler
and off we go

How can i use pik in win7?

I am using windows for rails.I installed pik for maintaining different versions of ruby.
But is there any possibility to create gemsets in PIK as in RVM?If not then how can i install different versions of rails?
Please help me..Thanks in advance!!!
Pik saved my life. I've been using rails 2.3.8 at work. I wanted to try the new rails 3.1 for my personal use. They told me to install RailsInstaller. But that screwed up all my rails 2.3.8 settings. So here's what I did.
I went to rubyinstaller. Downloaded installer for versions Ruby 1.8.7-p302 and Ruby 1.9.2-p290 installed them.
I installed both versions of ruby
then i installed the gem pik (see https://github.com/vertiginous/pik)
Now, I can switch between Ruby 1.8.7 and 1.9.2 using pik easily
pik 187 (switches to ruby 1.8.7)
So, I switched to ruby 1.8.7. and then installed rails 2.3.8
gem install rails -v 2.3.8
then i said pik 192 which switched the ruby to 1.9.2. Then i said
gem install rails -v 3.1.0
Now to use rails 2.3.8 all I have to do is say pik 187. Not only it switches ruby to 1.8.7 it also switches rails to 2.3.8
I am not a Ruby or Rails expert. But the key to remember is that you need to have the right Ruby version selected while installing rails. Meaning, if you're installing rails 3.1.0 make sure your current ruby version is 1.9.2 or higher or whatever version rails 3 works on. Similarly if you want to install rails 2.3.8 make sure your current ruby version is 1.8.7
Hope this helps. And people won't lose sleep because of this, like i did.
As far as I know, pik doesn't have this feature (yet).
As PIK is no longer maintained, see this commit comment. I would suggest to checkout URU to have version support in Windows (also supports linux and OSX)

How to update Ruby on Ubuntu 10.10?

Apologies in advance if this is a too nubs problem.
One friend got Beginning Rails 3 and we started playing Ruby using it (as .net developers!). I have installed Ubuntu 10.10 on VMWare Player - which apparently already had Ruby 1.9.2. Based on instructions in the book (with some quirks for total linux nubs) we managed to install Ruby 1.9.1 (ruby --version -> ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]).
But Rails (latest version - 3.0.2 I think) insist that Ruby 1.9.2 is better for our health!
So: How to update Ruby on Ubuntu 10.10? I want just this one ruby be there.
I recommend Ruby Version Manager.
Install (yes, it takes a leap of faith):
$ curl https://get.rvm.io | bash
then
$ rvm install 1.9.2
$ rvm use 1.9.2
The recommended way to manage Ruby versions is through RVM: http://rvm.io/
Rails is right about the Ruby versions, btw.

Can I install Ruby on Rails 2.x and Ruby on Rails 3 side by side

I have a Ubuntu rails enviroment for playing around with ROR.
Right now I am running Rails 2.3.8.
I want to look into rails 3. Is it possible to run both dev enviroments side-by-side?
If not, how do I clean up my rails 2.x system to install rails 3?
Or do I need to setup a whole new Ubuntu machine?
Any help, links... pointers would be great!
I would highly recommend Ruby Version Manager (rvm) - see this railscast for more information. This allows you to easily manage different versions of Ruby on the same machine. I believe this should also enable you to keep the different versions of Rails separate from each other, and allow you to switch between them easily - see this example from http://rvm.beginrescueend.com/gemsets/basics/ :
rvm 1.9.2-head
gem install rails -v 2.3.3
rvm gemset create rails222 rails126
Gemset 'rails222' created.
Gemset 'rails126' created.
rvm 1.9.2-head#rails222
gem install rails -v 2.2.2
rvm 1.9.2-head#rails126
gem install rails -v 1.2.6
Hope that helps!
For Windows users:
(I realize the asker uses Ubuntu, but this came up in the SERPs when I had a Windows-related question.)
You'll find that rvm isn't an option. You can use pik, however:
-- install the gem
> gem install pik
-- run 'install' command to add the utility to your system
> pik_install [some dir in your PATH variable]
-- tell pik where your Ruby versions are
> pik add C:\Ruby187\bin
> pik add C:\Ruby193\bin
-- see which versions pik has under control and which one is actively being used
> pik list
* 187: ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
193: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
-- tell pik to use a different version
> pik use 193
> pik list
187: ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
* 193: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
-- confirm the change worked:
> ruby -v && rails -v
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
Rails 3.2.3

Can I have/use different Versions of rails in the same machine

I am actually reading a rails book that is written for rails 2.3.5. I want to test Rails 3 beta as well. Is it possible to have such a setup in my Mac OS leopard?
I have tried with gem list -d rails. There are many versions stored in my mac but I don't know how to use different versions of rails while creating applications using rails command
While RVM is great there's no need for it in this use-case.
Install the Rails 3 gem: gem install rails—pre
Create new project: rails project_name (this will use the latest version installed)
To create projects with a specific version: rails _2.3.5_ project_name
Yes! Try rvm. It is awesome, you can have many different versions of Ruby, and for each one you can have different versions of gems. And you can run the same tests on all those versions. Isn't that cool?!
Quick How-To:
$ rvm install ruby-1.8.7 --default
$ gem install rails -v 1.0.0
$ rvm gemset create rails238
$ rvm 1.8.7#rails238
$ gem install rails -v 2.3.8
Now,
$ rvm 1.8.7
will give you ruby 1.8.7 and rails 1.0
And,
$ rvm 1.8.7#rails238
will give you ruby 1.8.7 and rails 2.3.8
You can make 2.3.8 as default one with
$ rvm use 1.8.7#rails238 --default
BTW rvm is documented really good.
The way to do this anymore is to use RVM, the Ruby Version Manager, which isolates different Ruby environments from each other.
A coworker of mine did a blog entry on setting up Rails 3 and RVM (and Ruby 1.9), which you might find interesting.

Resources