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!
Related
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.
I'm trying to deploy my Rails 3.0.1 application which works with Ruby 1.9.2.
However, I noticed that Rails 1.8.7 is installed on the server.
What steps should I take to install Ruby 1.9.2 on the server, and force my application to use it ?
I use Apache and Passenger.
I would recommend installing RVM and using that to set the version of Ruby that you want on the server.
Here's a rundown of its advantages in a production environment:
RVM allows users to deploy each
project with its own completely
self-contained and dedicated
environment--from the specific version
of ruby all the way down to the
precise set of required gems to run
the application. Having a precise set
of gems also avoids the issue of
version conflicts between projects,
causing difficult-to-trace errors and
hours of hair loss. With RVM, NO OTHER
GEMS than those required are
installed. This makes working with
multiple complex applications where
each has a long list of gem
dependencies efficient. RVM allows us
to easily test gem upgrades by
switching to a new clean set of gems
to test with while leaving our
original set intact. It is flexible
enough to even have a set of gems per
environment or development branch--or
even individual developer's taste!
It's very easy to setup and use, especially compared to managing the Ruby versions yourself. I've done both and I prefer RVM much more now. Once you have RVM installed, using Ruby 1.9.2 is as easy as:
rvm install 1.9.2
rvm use 1.9.2
And then you can check which version of Ruby your production environment is using with:
ruby -v
Assuming you use Apache, reinstall Passenger with
$ passenger-install-apache2-module
while having Ruby 1.9.2 active. If you use RVM just type rvm use 1.9.2 to make that version of Ruby active. Follow the on-screen instructions for how to modify your httpd.conf.
I set up RVM and used it to install Ruby and a few other libraries. As I was going through various tutorials and set-ups of other technologies like Rails, I began getting confused about what I should do via RVM and what I should just do as the tutorials suggest.
One example is the RubyGems tutorial here:
http://rubygems.org/pages/download
Should I download that tar file they are talking about? Seems unnecessary since that is what I thought RVM was for. Do I even need RubyGems? What is that for really?
Also, how do I actually get Rails? Is there a precise RVM command to actually download and install Rails?
It helps me to think of RVM as a layer of abstraction between you and the ruby ecosystem.
Without RVM: ruby, gems, and ruby related binaries (like rake, spec, gem, etc) are all installed directly into your operating system directories.
With RVM: ruby related stuff is intercepted by rvm so that ruby, gems, and ruby related binares are "installed" into ~/.rvm dir in a nice, clean, organized way. RVM sits between ruby, gems, and related binaries and the operating system. It provides a way to have multiple ruby environments (with different gems and binaries) on the same machine.
So, no matter whether you have rvm installed or not, you should be able to run the commands almost exactly(*) as they appear in any tutorials out there on the web. In other words, you can sort of "forget" that RVM is installed; the ruby ecosystem should work just as if it wasn't installed.
So, yep, you're gonna have to run gem install rails, etc.
Hope that helps clear the confusion.
(*) There are some small differences. For example: you shouldn't run commands as sudo when RVM is installed.
Should I download that tar file they are talking about?
No. Ruby 1.9+ includes gems. RVM retrofits it for 1.8+.
In general, be careful with any directions you find on the internet explaining how to install anything, unless you have enough experience to understand completely what they want you to do. In particular, any time they want you to install something using sudo or as root.
Specifically, when working with RVM, you do NOT want to use sudo to install Ruby, or any gem. RVM works by setting up a sandbox for your development, and relies on your account's environment, modifying your path so any Ruby requests go to the currently selected RVM-managed Ruby or gems or any commands they install. sudo pushes your normal environment to the side, substituting root's temporarily, installs whatever you asked it to do with root's permissions, then reverts to your environment.
When you go to run the command, or find the gem, as you, it can't be found by RVM's Ruby, because the file was installed outside RVM's sandbox, or, it can't be read or modified, because it's owned by root. Whatever the actual cause, the end result will be weeping and gnashing of teeth.
RVM doesn't subvert the gem functionality. gem is used to install and manage Ruby gems, and RVM tweaks it to use the sandbox for all its machinations. You get added functionality because of RVM's support of gemsets, but gem works as it always has, only it has "big brother", RVM, controlling its world.
No need to install rubygems. RVM should have already installed rubygems. RVM is (in my opinion) useful for managing different installations of ruby (say 1.8.7 and 1.9.2) or different gemsets. If you just have one version of ruby and don't care about different gemsets, RVM isn't really that much of a change. If you want to just install rails, just use gem install rails. If you have an existing rails 3 app, install bundler first gem install bundler and then bundle install to get rails and other gem dependencies.
I just got a new MacBook Pro and would like to install / upgrade the the Ruby on Rails stack specifically. My question is whether I should sudo all the installs / upgrades. The usual suspects of what I plan to install / upgrade are: Ruby, Gems, Rails, MySQL, sqlite3, PostgreSQL, RVM, Nginx, Passenger. I understand that RVM can be installed with different levels of access, root vs admin user, etc. Anyone knows what's the preferred way of installing RVM?
UPDATE
I know that LAMP isn't RoR, I just thought it was more inclusive seeing that it included web server, database, etc. Anyway, my bad, I have removed it from the post to avoid confusion. I have installed all the various components before, so this isn't a question about how to install them, this is a question about if I should install them as root or just the usual admin user.
Apache comes installed; edit the configuration file here: /private/etc/apache2/httpd.conf. To start/stop apache, open your System Prefrences.app, go to Sharing, and click the checkbox next to Web Sharing.
For MySQL, simply download the dmg and install http://dev.mysql.com/downloads/mysql/
sqlite3 comines installed
PostgreSQL: http://www.postgresql.org/download/macosx
How to install RVM: http://rvm.beginrescueend.com/rvm/install/
Update your ruby gems: sudo gem update --system
Update rails: gem update rails
Bonus: Awesome package manager for MacOS: https://github.com/mxcl/homebrew. You don't actually need this for the things you listed above, but I would highly recommend this if you plan on compiling/installing any additional packages on your system. (You'll need to install Xcode for this.)
PS: You don't actually mean "LAMP" as the P stands for PHP.
I know this is a little old, but the same concept applies. Excellent tutorial on how to do what you're asking for the best way.
Hivelogic Tutorial
I am looking for a piece of software that will allow me to use Ruby on Rails 2.3.8 on top of MACOSX - basically, I teach at a college where students are not able to get terminal acccess to the rails built into OSX so I am looking for a piece of software like "Locomotive" that is an app that allows students to use rails without administrator access to the computer itself.
Any one have any ideas?
We will be using Rails 2.3.8
thanks.
I encourage you to teach 3.0, but each to their own. If your materials only cover 2.3.8 then it's missing out on a lot of goodies associated with 3.0 (such as Bundler). Anyway:
My primary fear with this is that you're going to have an un-upgradable version of Rubygems if you don't have system privileges. Some gems require a Rubygems version >= 1.3.5 or even better, 1.3.6. Latest is 1.3.7. Thankfully, there's a way around it.
You can do this by installing the rvm gem:
gem install rvm --install-dir ~/.gems
RVM is "Ruby Version Manager" and does what it says on the tin: manages different versions of Ruby on your system. It'd be helpful in your case because it works without modifying the system Ruby.
This will install the gem to the user's home directory rather than the default system path. Then you'll need to run the rvm-install command which, as of this writing is:
~/.gems/rvm-1.0.14/bin/rvm-install
Your version of RVM may be different. To install a new version of Ruby which people can (ab)use run:
rvm install ruby-1.9.2-p0
1.9.2 is the latest stable version of Ruby and I highly encourage you use it rather than the older 1.8.7.
This should come with the latest Rubygems and, for bonus points, won't muddle about with the existing ruby installation on the machine (which is probably impossible if you don't have admin rights).
From this point, you'll be able to use
rvm use ruby-1.9.2-p0
to "switch" to that specific ruby. From there, you'll be able to do run gem install rails -v 2.3.8 which will install Rails somewhere in ~/.rvm. The location is not important. What is important however is that now you'll have a rails command that you can use and then you can go from there.
Good luck!