Tuesday, April 3rd, 2012

Ruby on Rails: EPIC fail in Debian

I am attempting to install Ruby on Rails on my Debian system to obtain a non-bias review of Ruby of Rails and make a proper comparison of it to Django. Compared to installing Python and the latest version of Django on Debian, installing Ruby and Rails on Debian is the complete opposite experience. I followed the standard Rails installation guide, then also looked at the other guide which go through creating a simple blog. Both seem to lead me on an endless path of frustration. It seems Ruby on Rails on much easier to install for Windows and OS X users, but tedious at best for Linux users, or at least Debian ones. I ended up finding a guide online after some hunting, which explains a rather cumbersome hack to get Ruby on Rails all up and running on your Debian system. I call this process a hack, as Ruby and Rails should just work out of the box, like Python and it's many packages. I am trying to open minded about Ruby on Rails, believe me, I am trying...

Here is how I attempted to install Ruby on Rails(similar to how I would have installed Python/Django):

root@sys1:~# apt-get install ruby
Reading package lists... Done
Building dependency tree       
Reading state information... Done
ruby is already the newest version.
ruby set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

I already has ruby installed from another package I have(not rails).

root@sys1:~# gem
-su: gem: command not found
root@sys1:~# apt-get install rubygems
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  ruby1.8-dev rubygems1.8
Suggested packages:
  rubygems-doc
The following NEW packages will be installed:
  ruby1.8-dev rubygems rubygems1.8
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1154 kB of archives.
After this operation, 3322 kB of additional disk space will be used.
Do you want to continue [Y/n]? 
Get:1 http://ftp.debian.org/debian/ squeeze/main ruby1.8-dev amd64 1.8.7.302-2squeeze1 [886 kB]
Get:2 http://ftp.debian.org/debian/ squeeze/main rubygems1.8 all 1.3.7-3 [202 kB]
Get:3 http://ftp.debian.org/debian/ squeeze/main rubygems all 1.3.7-3 [66.7 kB]
Fetched 1154 kB in 3s (376 kB/s)  
Selecting previously deselected package ruby1.8-dev.
(Reading database ... 94637 files and directories currently installed.)
Unpacking ruby1.8-dev (from .../ruby1.8-dev_1.8.7.302-2squeeze1_amd64.deb) ...
Selecting previously deselected package rubygems1.8.
Unpacking rubygems1.8 (from .../rubygems1.8_1.3.7-3_all.deb) ...
Selecting previously deselected package rubygems.
Unpacking rubygems (from .../rubygems_1.3.7-3_all.deb) ...
Processing triggers for man-db ...
Setting up ruby1.8-dev (1.8.7.302-2squeeze1) ...
Setting up rubygems1.8 (1.3.7-3) ...
Setting up rubygems (1.3.7-3) ...

Didn't have the GEM command, so I needed to install rubygems, as per the Rails installation guide.

root@sys1:~# gem install rails
Building native extensions.  This could take a while...
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Successfully installed i18n-0.6.0
Successfully installed multi_json-1.2.0
Successfully installed activesupport-3.2.3
Successfully installed builder-3.0.0
Successfully installed activemodel-3.2.3
Successfully installed rack-1.4.1
Successfully installed rack-cache-1.2
Successfully installed rack-test-0.6.1
Successfully installed journey-1.0.3
Successfully installed hike-1.2.1
Successfully installed tilt-1.3.3
Successfully installed sprockets-2.1.2
Successfully installed erubis-2.7.0
Successfully installed actionpack-3.2.3
Successfully installed arel-3.0.2
Successfully installed tzinfo-0.3.32
Successfully installed activerecord-3.2.3
Successfully installed activeresource-3.2.3
Successfully installed mime-types-1.18
Successfully installed polyglot-0.3.3
Successfully installed treetop-1.4.10
Successfully installed mail-2.4.4
Successfully installed actionmailer-3.2.3
Successfully installed rake-0.9.2.2
Successfully installed thor-0.14.6
Successfully installed rack-ssl-1.3.2
Successfully installed json-1.6.6
Successfully installed rdoc-3.12
Successfully installed railties-3.2.3
Successfully installed bundler-1.1.3
Successfully installed rails-3.2.3
31 gems installed
Installing ri documentation for i18n-0.6.0...
Installing ri documentation for multi_json-1.2.0...
Installing ri documentation for activesupport-3.2.3...
Installing ri documentation for builder-3.0.0...
Installing ri documentation for activemodel-3.2.3...
Installing ri documentation for rack-1.4.1...
Installing ri documentation for rack-cache-1.2...
Installing ri documentation for rack-test-0.6.1...
Installing ri documentation for journey-1.0.3...
Installing ri documentation for hike-1.2.1...
Installing ri documentation for tilt-1.3.3...
Installing ri documentation for sprockets-2.1.2...
Installing ri documentation for erubis-2.7.0...
Installing ri documentation for actionpack-3.2.3...
Installing ri documentation for arel-3.0.2...
Installing ri documentation for tzinfo-0.3.32...
Installing ri documentation for activerecord-3.2.3...
Installing ri documentation for activeresource-3.2.3...
Installing ri documentation for mime-types-1.18...
Installing ri documentation for polyglot-0.3.3...
Installing ri documentation for treetop-1.4.10...
Installing ri documentation for mail-2.4.4...
Installing ri documentation for actionmailer-3.2.3...
Installing ri documentation for rake-0.9.2.2...
Installing ri documentation for thor-0.14.6...
Installing ri documentation for rack-ssl-1.3.2...
Installing ri documentation for json-1.6.6...
Installing ri documentation for rdoc-3.12...
Installing ri documentation for railties-3.2.3...
Installing ri documentation for bundler-1.1.3...
Installing ri documentation for rails-3.2.3...
Installing RDoc documentation for i18n-0.6.0...
Installing RDoc documentation for multi_json-1.2.0...
Installing RDoc documentation for activesupport-3.2.3...
Installing RDoc documentation for builder-3.0.0...
Installing RDoc documentation for activemodel-3.2.3...
Installing RDoc documentation for rack-1.4.1...
Installing RDoc documentation for rack-cache-1.2...
Installing RDoc documentation for rack-test-0.6.1...
Installing RDoc documentation for journey-1.0.3...
Installing RDoc documentation for hike-1.2.1...
Installing RDoc documentation for tilt-1.3.3...
Installing RDoc documentation for sprockets-2.1.2...
Installing RDoc documentation for erubis-2.7.0...
Installing RDoc documentation for actionpack-3.2.3...
Installing RDoc documentation for arel-3.0.2...
Installing RDoc documentation for tzinfo-0.3.32...
Installing RDoc documentation for activerecord-3.2.3...
Installing RDoc documentation for activeresource-3.2.3...
Installing RDoc documentation for mime-types-1.18...
Installing RDoc documentation for polyglot-0.3.3...
Installing RDoc documentation for treetop-1.4.10...
Installing RDoc documentation for mail-2.4.4...
Installing RDoc documentation for actionmailer-3.2.3...
Installing RDoc documentation for rake-0.9.2.2...
Installing RDoc documentation for thor-0.14.6...
Installing RDoc documentation for rack-ssl-1.3.2...
Installing RDoc documentation for json-1.6.6...
Installing RDoc documentation for rdoc-3.12...
Installing RDoc documentation for railties-3.2.3...
Installing RDoc documentation for bundler-1.1.3...
Installing RDoc documentation for rails-3.2.3...

Here are a few things I didn't expect... rails was not added to my path, so I needed to manually add /var/lib/gems/1.8/bin, which I found very annoying. Ruby is starting to remind me of how we were promised Plug'n Play in Windows '95. It wasn't really Plug 'n Play.

kveroneau@sys1:~/ror$ rails new blog
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.2.2) 
Using i18n (0.6.0) 
Using multi_json (1.2.0) 
Using activesupport (3.2.3) 
Using builder (3.0.0) 
Using activemodel (3.2.3) 
Using erubis (2.7.0) 
Using journey (1.0.3) 
Using rack (1.4.1) 
Using rack-cache (1.2) 
Using rack-test (0.6.1) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.1.2) 
Using actionpack (3.2.3) 
Using mime-types (1.18) 
Using polyglot (0.3.3) 
Using treetop (1.4.10) 
Using mail (2.4.4) 
Using actionmailer (3.2.3) 
Using arel (3.0.2) 
Using tzinfo (0.3.32) 
Using activerecord (3.2.3) 
Using activeresource (3.2.3) 
Using bundler (1.1.3) 
Using coffee-script-source (1.2.0) 
Using execjs (1.3.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.6.6) 
Using rdoc (3.12) 
Using thor (0.14.6) 
Using railties (3.2.3) 

Gem::Exception: Cannot load gem at [/var/lib/gems/1.8/cache/coffee-script-source-1.2.0.gem] in /home/kveroneau/ror/blog                                                                                   
An error occured while installing coffee-script-source (1.2.0), and Bundler cannot continue.
Make sure that `gem install coffee-script-source -v '1.2.0'` succeeds before bundling.

This is the last thing I would expect from one of the world's best web frameworks(or so I have heard), it did this many times before it finally worked. Shouldn't Rails have installed all the required deps via GEM? Or is this not how a package manager is suppose to work? Ruby really is full of surprises, many of which are not user-friendly. Here are the deps I needed to manually install myself:

root@sys1:~# gem install coffee-script-source -v '1.2.0'
Successfully installed coffee-script-source-1.2.0
1 gem installed
Installing ri documentation for coffee-script-source-1.2.0...
Installing RDoc documentation for coffee-script-source-1.2.0...
root@sys1:~# gem install execjs -v '1.3.0'
Successfully installed execjs-1.3.0
1 gem installed
Installing ri documentation for execjs-1.3.0...
Installing RDoc documentation for execjs-1.3.0...
root@sys1:~# gem install coffee-script -v '2.2.0'
Successfully installed coffee-script-2.2.0
1 gem installed
Installing ri documentation for coffee-script-2.2.0...
Installing RDoc documentation for coffee-script-2.2.0...
root@sys1:~# gem install coffee-rails -v '3.2.2'
Successfully installed coffee-rails-3.2.2
1 gem installed
Installing ri documentation for coffee-rails-3.2.2...
Installing RDoc documentation for coffee-rails-3.2.2...
root@sys1:~# gem install jquery-rails -v '2.0.1'
Successfully installed jquery-rails-2.0.1
1 gem installed
Installing ri documentation for jquery-rails-2.0.1...
Installing RDoc documentation for jquery-rails-2.0.1...
root@sys1:~# gem install sass -v '3.1.15'
Successfully installed sass-3.1.15
1 gem installed
Installing ri documentation for sass-3.1.15...
Installing RDoc documentation for sass-3.1.15...
root@sys1:~# gem install sass-rails -v '3.2.5'
Successfully installed sass-rails-3.2.5
1 gem installed
Installing ri documentation for sass-rails-3.2.5...
Installing RDoc documentation for sass-rails-3.2.5...
root@sys1:~# gem install sqlite3 -v '1.3.5'
Building native extensions.  This could take a while...
Successfully installed sqlite3-1.3.5
1 gem installed
Installing ri documentation for sqlite3-1.3.5...
Installing RDoc documentation for sqlite3-1.3.5...
root@sys1:~# gem install uglifier -v '1.2.4'
Successfully installed uglifier-1.2.4
1 gem installed
Installing ri documentation for uglifier-1.2.4...
Installing RDoc documentation for uglifier-1.2.4...

Now, finally the rails bootstrap application works! It took long enough, and I though I would be done with this, but... I wasn't...

kveroneau@sys1:~/ror/blog$ rake db:create
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

(See full trace by running task with --trace)

This is where I finally got completely stuck and frustrated. I went to the website provided and tried installing therubyracer, and even the rubyrhino, and for some odd reason, rake wasn't able to see either of them... REALLY? I have offically given hope at installing Ruby on Rails, the way I easily installed Python and Django. These are obviously too completely different beasts. I would think, given Rails' reputation, Rails would be the easy one to install, and Django would be the one I need to manually compile and such. This unfortunately gives me yet another reason why I enjoy Python and Django so much, compared to the competition. How do rails developers deal with this ordeal? The installation itself it a pain.

Comment #1: Posted 2 years, 8 months ago by Senthil Nayagam

Kevin,


Rails installation have become a bit complicated in since rails 3 , hope bundled goes the rubygems, rack, rake way and become a standard installation soon with all ruby distributions.
JavaScript runtime dependency for coffeescript should have been for 20% configuration crowd instead of the 80% convention crowd who face install issues.
Will do a blog post/screencast on setting up ruby and rails on various platforms and share it here and HN by this weekend

Comment #2: Posted 2 years, 8 months ago by Jayson Rowe

I've never set up RoR on plain Debian, but it works quite nicely on Ubuntu...and *where* did you get the idea that Ruby OR Rails installs easily for Windows users? I've found it to be nearly impossible, yet Mac and Ubuntu have been pretty similar experiences. As for your last error, try installing nodejs from apt-get - that should get that fixed for you. If you check my blog, I have a pretty decent guide for Ubuntu (or at least I think so), and it would probably translate pretty easily to Debian. Good Luck!

Comment #3: Posted 2 years, 8 months ago by Jayson Rowe

oh...and BTW, using RVM for Ruby instead of the package repos would probably be easier as well...

Comment #4: Posted 2 years, 8 months ago by Joe

I'm not sure what your problems were but I did install Rails back in November (see https://pyrseas.wordpress.com/2011/12/19/design-notes-on-database-application-development/) on Debian. From what I recall, I didn't have much problem with Ruby or Rails, only some issues with getting the correct PostgreSQL adapter.

Comment #5: Posted 2 years, 8 months ago by Andreas

I wonder why you didn't just install the "rails" via APT? I didn't actually try this right now, but it does sound like being a lot easier since it'll have proper dependencies set :)

Comment #6: Posted 2 years, 8 months ago by Andrew Swihart

I'm sure this is easy if you know what to do and what not to do. In the Python world, using pip for almost everything is the way to go. For Rails, I guess you have more than one option: gem, rvm, apt...which is the fool-proof / recommended way?

Comment #7: Posted 2 years, 8 months ago by Kevin Veroneau

@Senthil, I look forward to that post/screencast.

@Jayson, For windows users I found a custom installer for them. I only assumed it would be easy going from there: http://railsinstaller.org/, I will check your website and see if your guide helps with the installation, thanks.

@Andreas, I didn't use APT as it tends to have very old versions. I install Django via pip for example, as Debian comes with an out dated version. Squeeze only has 2.3.5, and Rails is at version 3.2. I only install the main binaries via APT, Python2.6/Ruby1.8, and use the Python-specific package manager for Python package management. I would have hoped this worked the same in Ruby. :(

Comment #8: Posted 2 years, 8 months ago by Israel Fruchter

BTW, I think
http://bitnami.org/stack/rubystack

is the easiest way to install ruby on rails both on windows and linux

Comment #9: Posted 2 years, 8 months ago by Mark Thomas

RVM is the best way to install Ruby and Rails on a Debian-based system (well any linux, but in particular Debian). This is well known in the Ruby community, which shuns the apt repo packages. It has never been difficult for me to install (OK, except on Solaris, but that's a different story)

Comment #10: Posted 2 years, 8 months ago by reaper

I'm all for a good ruby bashing, but trying to work with ruby+gem without rvm/rbenv/rbfu is like working with python without virtualenv - painful at best.

Comment #11: Posted 2 years, 7 months ago by Kevin McCaughey

I had a similar experience on Ubuntu using RVM.... M Papais, one of the developers simply would not believe me that it didn't work. I think it's all the in-between bits that they do in autopilot they forget to document. These small bits (apt-get this, apt-get that, edit this config file, etc) are what means it installs and works.

Don't be led to believe though that after the install goes ok then you are on home ground, oh no. After that you will have daily little bugs that take you about 7 pages into google to some obscure blog just to solve.

I'm at it three months now and if I had one comment to make it is that ALL development on R/RoR should stop and the entire communit should start the (probably year long) task of fixing and documenting it properly. This goes for the install and all the frameworks.

It's a mess, a total mess. But, when it works, it does a good job.

Comment #12: Posted 2 years, 7 months ago by Micha

On Debian 6 it's a nightmare - simple as that. Try to install it on a fresh system via apt-get and you will give it a second glance ....

For example ... you have to install ruby1.8-dev to get mkmf and that's what apt-get throw at you

The following packages have unmet dependencies:
ruby1.8-dev : Depends: libruby1.8 (= 1.8.7.302-2squeeze1) but 1.8.7.352-2 is to be installed
Depends: libc6-dev but it is not going to be installed
Recommends: ruby1.8 (= 1.8.7.302-2squeeze1) but 1.8.7.352-2 is to be installed

Don't even bother with apt-get install libc6 or whatever idea you might get. Basically you have to resolve around 60 dependencies, ruin half the system for a simple Framework? That IS an epic fail. Only reason we had it run was Redmine and even the Redmine DevTeam is complaining about the 'crappy mess' the Framework has become.

Instead of new features of gimmicks i would highly recommend 3 months of solid bugfixing.

Comment #13: Posted 2 years, 7 months ago by Filomenat Linel

I’ll immediately grab your rss as I can't find your email subscription link or newsletter service. Do you have any? Please let me know so that I could subscribe. Thanks.

Python Powered | © 2012-2014 Kevin Veroneau