Would it be worth migrating a ruby install to RVM? - ruby-on-rails

Several months ago, I installed ruby 1.9.1 on Mac OSX 10.6 using the instructions here, modified for the newer versions of ruby/rails/gem.
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/
A project has now come up where I need to develop a site using an older version of rails, and consequently, an older version of Ruby. I've successfully installed RVM, older versions of gem and the rails gems, but now I'm mildly worried about my environment. Technically, I have 3 groups of Ruby installs floating around - the native 1.8.7 that was included with OSX 10.6, my own 1.9.1 installed in /usr/local/, and 1.8.7 in RVM.
I'm concerned that this could cause strange, difficult to diagnose errors in the long run. Would it be worth the trouble of uninstalling my 1.9.1 /usr/local and/or the baked-in 1.8.7, and installing them in RVM?

All the Rubies you use for development should be under rvm (or rbenv, as John comments). It avoids the headaches you describe--nothing more exciting than having a surprising library pulled in.
While I have removed the system Ruby on some OS X machines and not been affected by it, the Tin Man's point about not removing it outright seems reasonable, and rvm makes it unnecessary to do so. Some tools, like brew, rely on having a Ruby available; if you do remove it, you'll need to make sure that everything the system Ruby had is still available to prevent breakage.

RVM also supports the use of its own and the system ruby interchangeably. I've made use of that before, but I also agree with Dave, in that you should probably just move into the RVM world, it won't take much more effort and gives much in return.
ryanmt#Hermes:~$ rvm use system
Now using system ruby.
ryanmt#Hermes:~$ rvm use default
Using /home/ryanmt/.rvm/gems/ruby-1.9.2-p290

I'd propose a halfway house - install the other rubies in RVM and test the apps running under those with the RVM rubies? If they work, then move completely over the RVM. If they don't, you haven't lost anything, just don't use RVM for those apps. You don't need to uninstall the originals to do this.

Don't remove Apple's Ruby, but do install RVM. You probably should remove the one in /usr/local.

Related

windows 7 64-bit - can't upgrade upgrade to ruby 2.0 keeps showing 1.9.3 - can't switch to new installation

I've looked through all of the topics on here and cannot find an answer.
All of the answers say to use RVM or PIK but I am on windows and pik is outdated/unusable.
When I deleted all of the ruby 1.9.3 files and typed ruby -v it showed my 2.0 was running.
However when I deleted the ruby files, rails 4.0 got uninstalled.
Everytime I reinstall rails from railsintsaller.org it reboots the 1.9.3
I tried switching the paths in computer > properties > advanced system settings but not sure if that helps or if I got it right.
It is really frustrating that the newest rails download overwrites the lates ruby files and knocks me back a version.
Can anyone help me I am on Windows 7 Home Premium 64 bit...not a lot of help for this system out there...
Jesse,
Speaking from experience, Pik is a viable solution if you want to run both versions of Ruby on the same Windows box (at least until RVM 2 is released with Windows support). It should only require adding the Ruby from the RailsInstaller installation to Pik so that it is aware. Then, you should be able to use Pik and install other versions of Ruby.
The other option that is a bit more complicated is using Cygwin. This will actually allow you to install RVM and run it in a sandboxed Unix environment on Windows. It's something that I've been meaning to write up how to do but just haven't gotten around to it.
Cheers,
Evan

Upgrade to ruby 1.9.3 with rvm or brightbox gems

I currently use rvm on my dev box (osx) but I use the system ruby on my server (1.8.7 on Ubuntu 10.04)
I want to upgrade the server to 1.9.3 and have been researching the best way to do it.
The server is running about four Rails applications all on version 3.2.11.
My options appear to be using rvm or alternatively using the 1.9.3 deb package and the ruby-switch gem provided by BrightBox (who also provide passenger packages)
The Brightbox packages appear to be a clean way to go but I thought I would ask a question here to see if there are any advantages or disadvantages of either approach that I have not thought about.
Rvm is useful when you need to have two or more versions of Ruby on the same machine. Development machines tend to have this. There is no need to use a version manager if your production box only requires one version of Ruby.
To this effect, I'd suggest you're correct in doing a single installation from the deb package. I can see the ruby-switch gem gives similar functionality to rvm - up to you as to whether that's important. But if you're using three apps on the same version of ruby, it may not be!

Trouble understanding RVM, gems, and general Ruby on Rails environment setup

I've read through a few Q&A's here on this subject, but am still confused. I'm new to linux and new to programming, so please keep that in mind.
I understand that Ruby Gems is similar to apt-get. It's a package manager -- correct?
So if I want to install or remove gems, I can do it via a command like: sudo gems install {gem name}
So what then is RVM? Why would I want to use it? Doesn't Ruby Gems do what RVM does? Why then does Ruby Gems get installed with RVM?
Also, when specifying gems in a project's Gemfile, then using bundler to update, etc.. is this downloading the gems only to that project, or will they now be available across all projects?
Also, what is $PATH about? I don't know much about it, so when I read about it, I'm confused about what is the right $PATH, what if anything I should do to manage references in $PATH, etc. Can someone explain or point to any resources for beginners?
And finally, I'm using various tutorials, and they differ on versions for everything from Ruby to Rails to Gems. a) Should I be modifying my environment to match the version that they use? b) Once I'm done with a tutorial, should I leave all the versions alone, or should I try to upgrade everything up to the latest and greatest?
It's confusing because if I leave everything at the version levels in the tutorials, then I feel like I'm stuck in the past. While if I upgrade to the latest and greatest, I feel like things have all switched around on me and I'm not sure how to use all the tips and tricks I learned.
Thank you in advance for taking the time to help. Cheers.
This question is very broad so I chose to try to balance the explicitness with conciseness. If anyone finds anything wrong with the answer please tell and I'll straight up own up to it :)
RVM is a Ruby Version Manager. Hypothetically, some projects might require you to run ruby 1.9, another legacy project might require 1.8. RVM allows you to have both installations installed side-by-side, as opposed to having one authoritative system-level version of ruby. This facilitates installing later versions of ruby without fear of breaking anything, or of meddling with other user accounts' ruby version requirements (since usually one installs RVM at the user level, in your home directory). This even lets you try out the bleeding edge version of ruby without having anything to worry about, since you can always switch back easily.
When you install a gem, it generally becomes available to you everywhere that ruby installation is available to you, so in any project. When you specify gems in your Gemfile you're basically saying that independently of whatever gems you may have installed and their versions, that project requires gem x of version 2.2, y of version 3.1, and z of version 1.1. If you didn't already have those gems it installs them, if you did but not those versions, it installs them.
Path is an environment variable that allows operating systems to know where to look for programs when you invoke them. If you type someapp in the terminal, how can the operating system possibly know where someapp is? Well it searches for it in any of those directories supplied in $PATH. You can see what's in your path by doing echo $PATH in the shell.
As for varying versions of ruby, this brings me back to the reason for RVM. You can if you want install the version of ruby they use, and then in your Gemfile specifically state the version of the gems the tutorials use and you should be fine. You can have different versions of gems installed, and you can have different versions of ruby installed thanks to RVM.
Personally I would recommend working towards the latest version of everything so that it remains relevant. For example, it would be counterproductive to work on a tutorial that uses Rails 2 since it changed a lot when it went to 3, and somewhat from 3 to 3.1 and above etc. If possible use the latest versions, or at least be aware of the nuances (the base material tends to stay more or less the same), lest you work on a tutorial that is older only to get to work on your own project with the latest version of everything and not have it work.
Simple solution to your dilemma: ditch the tutorials that are too old. There are tons of resources out there that you're bound to find up-to-date material. Worst case, dated material typically has community support in form of comments which state the changes between the dated version of something and its corresponding recent version. E.g. "keep in mind that haha.what changed to lol.wut in version 3.1"
I can understand that this is confusing, RubyGems are as you write a package manager. RVM is a tool that makes it possible to have several versions of ruby installed on your system and easy swift between them.
If you using various tutorials, and they differ on versions for everything from Ruby to Rails to Gems you can (if you want to) create a RVM Gemset for the version you use. You will then create a sandbox for the Gems Bundler use in your project.
Bundler are as you write a tool for manage the Gems your application depends on. In the old days before Bundler it could be a hassle to figure out which gems your application depended on. Now Bundler do this for you.
Both Bundler and RVM are tools that is not absolutly necessary to use but they will help you. I personally do not use RVM anymore. It is to much of a monster in my taste so I use rbenv instead.
Regarding what versions of Rails to use I do agree that you should try to use 3.1 versions if possible but if you find some example application using Rails 3.0 you do not need to upgrade it. Also you do not need to run the absolute latest version of Rails. Rails 3.1 have a lot of bug fixes that the latest Rails 3.1.3 might not have.

Completely reinstalling Ruby Rails and Gem on Mac OS X

I've recently started teaching myself Ruby on Rails, and it's all going well except I'm looking to completely reinstall Ruby, Rails and Gem.
I think I got a bit too excited at some point and deleted/modified some files or folders I shouldn't have, so I just want to get my system back to its original state so that I can reinstall the necessary Ruby, Rails and Gem bits.
I've read in places that I can install something called rvm to do this, but right now I just want to keep my system as simple as possible so that my understanding can keep up.
Any help would be appreciated.
Many thanks.
You list all the gems which are installed in your user account, with:
gem list
You can then delete any of the gems, by doing this:
gem uninstall GemName
... until gem list doesn't show any installed gems.
After that, everything should be as good as new.
I would highly recommend to install RVM, because it will help you not to get into the same situation in the future. With RVM you can create "gemsets" to keep the gems for each project separate from other projects.
With RVM you can also install different versions of Ruby, such as the newer Ruby 1.9.2
Check it out! It's really not difficult to install
http://beginrescueend.com/
Check these RailsCasts:
http://railscasts.com/episodes/200-rails-3-beta-and-rvm
http://railscasts.com/episodes/201-bundler
If you are on Max OSX 10.5 and up, Ruby and RubyGems is installed with Developer Tools.
On older versions you could uninstall by running this command:
$ sudo perl /Developer/Tools/uninstall-devtools.pl
Then you just need to reboot your computer and install Developer Tools again. After that if you want to use RVM follow the instructions here. There are also some OSX specific options you should go over as well.
You could follow the instructions on the RoR site - the download page also includes instructions. Another option is this one click installer from the Ruby OS X project on SourceForge.
If you have a TimeMachine backup available, you could also choose to restore your deleted files instead of reinstalling.
The simplest way is to use rvm to do this. The advantage to this is that everything's installed in a manner that's specifically isolated from the system.
Using the OS or MacPorts/Homebrew provided Ruby is a great way to get going, but it doesn't scale. For the long-haul, it's best to use rvm because it is easier to stay up to date, to install different versions of Ruby, and to switch back and forth with a minimum of pain.
Plus, if you really get sideways you can always rvm implode and start over, which when combined with bundler will make life pretty easy.

Is the default Ruby install on Mac OSX 10.5 "good enough" for Rails development?

OSX 10.5 comes with Ruby 1.8.6 I believe, but I see a lot of tutorials that recommend installing the latest version of Ruby from source. I've done this in the past and it's caused minor issues down the road if I install something which expects Ruby to be in the default location and it's not (Phusion Passenger pref pane, for instance).
What I'm wondering is if the default version of Ruby is good enough to use for development purposes, so there's no conflicts or multiple versions of Ruby floating about? Obviously the default Rubygems and Rails versions would need to be upgraded, but I'm specifically wondering about the default version of Ruby that comes with 10.5.
Rails 3 will require Ruby 1.8.7 and we're already recommending 1.8.7 for Rails 2.3.4. I'd strongly recommend upgrading.
1.8.6 will be fine for a local dev box. Personally I always install what's on the production box -- usually Ruby Enterprise -- but yea, if you don't want to deal with the hassles involved with replacing ruby entirely, there's no big disaster waiting for you with the stock stuff.
If you do want to keep current (probably a good idea for a serious application) and make sure you're running the same ruby as your production environment then you could try this tutorial (I've used a previous iteration) on handling those hassles.
The Rails team themselves recommend Ruby 1.8.7 for doing Rails development with any of the most recent releases.
I'd also highly recommend that you use the same version of Ruby for development as what will be in your 'production' environment. Avoids surprises.
The Ruby on Rails download page recommends 1.8.7 but says 1.8.6 still works and I'm finding no problems.
I personally do not like the Ruby implementation on the Mac, as I had a a lot of problems with MySql, Postgres, and other gems, always being obscure compilation problems which required me to install XCode and then compile all sorts of obscure libraries. In the end I solved my problems by installing Ubuntu 8.10 on VirtualBox under the Mac, and now everything works great!!!!
Also, when I switched to Snow Leapard I had a lot of the Ruby gems break as well. Also, I would recommend using Ruby 1.9, definitely much faster than 1.8.6 IMHO, again, running best on Ubuntu, NOT Mac.
I guess I would also like to add that many Unix die hards will disagree with me on this post, as things on the Mac CAN be made to work, but I guess I'm just lazy, and would rather have things "work out of the box".
I run REE (Ruby Enterprise Edition) simply because it runs my specs faster than the regular version (about 20%, sometimes more).
It's also nice that it comes with passenger and some of other things you usually want.

Resources