Posted by & filed under geek, howto.

railsUPDATE: Thanks to Ryan, Ant and Fern for the tips.  With that in mind I found an online Slicehost tutorial that contained the steps and explained how to install ruby via apt-get, then get the latest rubygems, install that manually, ran gem to update itself, then run gem to install rails – as suggested.  The steps I took from that page:

On a Debian Lenny system that does not have ruby, rubygems or rails installed on it yet:

apt-get update
apt-get upgrade
apt-get install ruby-dev ruby ri rdoc irb libreadline-ruby libruby libopenssl-ruby sqlite3 libsqlite3-ruby libsqlite-dev libsqlite3-dev

Once that completes without errors, make sure ruby is installed and ok:

ruby -v

Now download the latest rubygem (1.3.5 as of this post) from RubyForge http://rubyforge.org/frs/?group_id=126:

wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz

Unpack it, change into the directory, run setup:

tar xzvf rubygems-1.3.5.tgz
cd  rubygems-1.3.5
ruby setup.rb

After that you’ll see:

RubyGems 1.3.5 installed

Then it’s suggested that you make a symlink to gem1.8 so you can run it as gem:

ln -s /usr/bin/gem1.8 /usr/bin/gem

Now make sure everything is up to date (even though we just installed the latest):

gem update
gem update --system

And finally – install rails:

gem install rails

After this you can check what gem has installed, and their version numbers:

gem list

And there you have it, more steps than I wanted, but now I know how to have a Debian system up to date, with Ruby, and then having rubygems handling all of the other ruby things that are better dealt with as gems.  As for systems I already have running in production in mixed enviroments?  I’ll look to migrate those to properly configured installs in the future. I guess for extra credit I should contact the maintainer of rubygems, and the associated gems, for Debian to get their side of the story, or maybe a solution they could put in place moving forward.

Original post:

I’ve been using Ruby on Rails on and off for many years now, and friends are always showing me new RoR apps to try out that look fly.  I can get things up and running fine, but it’s when the time comes to update an app that I have issues; I seem to come to the fork in the road where apt-get doesn’t have the latest version of Rails or some dendancy, and gem install is the proposed solution. I worry that mixing the two updating procedures will mess things up, since I have seen this before in Debian GNU/Linux, as well as FreeBSD (I suspect it’s me, and there’s a right way to do it). So, for example, today I noticed there was a new version Redmine a few days ago, so I update to the latest via SVN (the suggested way of updating Redmine):

# cd /opt/redmine-svn
# svn up
At revision 3076.

Now I copy in the email.yml and database.yml from my working instance so this will use the same config:

# cp /opt/redmine/config/database.yml /opt/redmine/config/email.yml config/

So far so good, let’s rake it up:

# RAILS_ENV=production rake db:migrate
(in /opt/redmine-svn)
Missing the Rails 2.3.4 gem. Please `gem install -v=2.3.4 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

So here we are, crap, what version of Rails do I have installed via apt-get?

# apt-cache showpkg rails | head -n3
Package: rails
Versions:
2.2.3-1 (/var/lib/apt/lists/ftp.debian.org_debian_dists_squeeze_main_binary-i386_Packages) (/var/lib/dpkg/status)

Damn, so what version of Debian am I running?

# cat /etc/issue.net
Debian GNU/Linux squeeze/sid

Yep, the latest, testing branch. So here I am, do I leave the apt-get world and start up gem install or what? My hesitation is that this is my ‘production’ version of Redmine, and I don’t really want to build out a sep install just to test my Rails updating, and if I do that, will the gem Rails install hose my current apt-get installed Rails anyway? So this is the problem I’ve had since I started playing with Rails apps, and it’s been about 3 years now (fak3r.com was on Typo for almost a year).  I’m open to suggestions as to how others handle this, do you just install Debian and then not even use apt-get for Rails/Ruby stuff? It seems that gem install always have the most up to date stuff, I’m just concerned that updating things that way will interfere with an apt-get update; apt-get upgrade of the main system later, particularly now that I’m already in the apt-get side.  Do I reinstall and go all gem install for just Ruby stuff, and apt-get just for the system?  How do people segment this?  There has to be a proper way that I’m missing.

Comments?

  • http://ryanschenk.com/ The Schenk Tank

    Rails is a gem, and should be managed with RubyGems, not with apt.I would recommend installing and managing the Ruby interpreter with apt-get, and that's it. Leave Ruby package management to the tools that are expressly designed for this purpose. The nice thing about gems is that you can have multiple versions of Rails installed simultaneously, something I imagine you can't do with apt.

  • http://twitter.com/anthonygoddard Anthony Goddard

    +1 Schenk TankI either use the package manager to install ruby (or the sweet sweet rubyEE installer from source) and then let gems take care of the rest (installing the rails gem, etc etc). The last thing you want is multiple copies of gem installed and then multiple gems in different places

  • http://fak3r.com fak3r

    This makes sense, and I have a virtual instance now that I'll test it out on, guess I'm just wanting something where there was a hard and fast rule; edit this file, now apt won't install anything that you should use gem for… kind of like how you can do 'pinning' to have apt only use a certain version of an app, if you could set that for anything that gem could/should install instead of apt, that'd be cool.

  • http://ryanschenk.com/ Schenk

    Ant makes a good point. It IS possible to install multiple versions of ruby, gem, and rake on one box. If you do, your life will suddenly become extremely hellish.For instance, if you decide to switch from your apt installed ruby stack to ruby EE, you MUST make sure you completely remove any trace of the ruby stack you installed with apt before installing Ruby EE.Otherwise you will enter a world of pain. A world of pain, Smokey.

  • http://fak3r.com fak3r

    Wow, still reading up on this, others have this issue with different ways suggested to solve it, but just to try I did a gem updated, check this:# gem update –systemERROR: While executing gem … (RuntimeError) gem update –system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get.Obviously I don't want to go that route… so I wonder if I just drop ruby on Debain, then pull down rubygems and install it manually so apt doesn't get a hold of it.

  • http://fak3r.com fak3r

    Wow, while reading up on this (have done that before, but have basically given up) others have this issue with different ways suggested to solve it, but just to try I did a gem updated, check this:# gem update –systemERROR: While executing gem … (RuntimeError) gem update –system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get.Obviously I don't want to go that route… so it seems that I need to do what you guys are suggesting, apt-get ruby, wget rubygems latest, install that via ruby, then rubygems update, then gem install rails. Wow. So far the best guide I've seen is on Slicehost: http://articles.slicehost.com/2009/4/9/debian-l…Giving it a go on an up to date Lenny (debian stable)

  • http://ryanschenk.com/ Schenk

    Yes, just install Gems yourself then. It's seriously four lines.find the latest rubygems here: http://rubyforge.org/frs/?group_id=126wget the_latest_rubygems.tgztar -zxvf the_latest_rubygems.tgzcd the_latest_rubygemsruby setup.rb

  • http://ryanschenk.com/ The Schenk Tank

    Rails is a gem, and should be managed with RubyGems, not with apt.

    I would recommend installing and managing the Ruby interpreter with apt-get, and that’s it. Leave Ruby package management to the tools that are expressly designed for this purpose.

    The nice thing about gems is that you can have multiple versions of Rails installed simultaneously, something I imagine you can’t do with apt.

    • http://fak3r.com fak3r

      This makes sense, and I have a virtual instance now that I’ll test it out on, guess I’m just wanting something where there was a hard and fast rule; edit this file, now apt won’t install anything that you should use gem for… kind of like how you can do ‘pinning’ to have apt only use a certain version of an app, if you could set that for anything that gem could/should install instead of apt, that’d be cool.

  • http://twitter.com/anthonygoddard Anthony Goddard

    +1 Schenk Tank

    I either use the package manager to install ruby (or the sweet sweet rubyEE installer from source) and then let gems take care of the rest (installing the rails gem, etc etc).
    The last thing you want is multiple copies of gem installed and then multiple gems in different places

  • http://ryanschenk.com/ Schenk

    Ant makes a good point. It IS possible to install multiple versions of ruby, gem, and rake on one box. If you do, your life will suddenly become extremely hellish.

    For instance, if you decide to switch from your apt installed ruby stack to ruby EE, you MUST make sure you completely remove any trace of the ruby stack you installed with apt before installing Ruby EE.

    Otherwise you will enter a world of pain. A world of pain, Smokey.

  • http://fak3r.com fak3r

    Cool, that's exactly what I did, and it worked. Thanks, think I understand it now, and have a good system going forward. I'll post the steps in a bit.

  • http://fak3r.com fak3r

    w00t, it worked! Post updated with details, thanks again!

  • http://fak3r.com fak3r
  • http://fak3r.com fak3r

    Wow, while reading up on this (have done that before, but have basically given up) others have this issue with different ways suggested to solve it, but just to try I did a gem updated, check this:

    # gem update –system
    ERROR: While executing gem … (RuntimeError)
    gem update –system is disabled on Debian. RubyGems can be updated using the official Debian repositories by aptitude or apt-get.

    Obviously I don’t want to go that route… so it seems that I need to do what you guys are suggesting, apt-get ruby, wget rubygems latest, install that via ruby, then rubygems update, then gem install rails. Wow. So far the best guide I’ve seen is on Slicehost: http://articles.slicehost.com/2009/4/9/debian-lenny-ruby-on-rails

    Giving it a go on an up to date Lenny (debian stable)

    • http://ryanschenk.com/ Schenk

      Yes, just install Gems yourself then. It’s seriously four lines.

      find the latest rubygems here: http://rubyforge.org/frs/?group_id=126

      wget the_latest_rubygems.tgz
      tar -zxvf the_latest_rubygems.tgz
      cd the_latest_rubygems
      ruby setup.rb

      • http://fak3r.com fak3r

        Cool, that’s exactly what I did, and it worked. Thanks, think I understand it now, and have a good system going forward. I’ll post the steps in a bit.

  • http://fak3r.com fak3r

    w00t, it worked! Post updated with details, thanks again!

  • tonybuy

    multiple DVD Case,Slim DVD Case,Standard DVD Case 3 way DVD Case,4 way DVD Case,5 Way DVD Case Mnaufacturer from China.———http://www.media-packs.com/multi-multiple-dvd-case-box...

  • Pingback: Install packages through apt-get or gem? Drija