Tuesday, August 21, 2012

Rails Tutorial vs. Heroku

Continuing our trek into Rails...

Since Hartl's guide to Rails recommends Heroku for deploying apps, I followed his instructions. Everything went smoothly until I hit the first perplexing roadblock of this trip (all the others heretofore have been minor—astonishingly painless, really).

I was able to log in to Heroku, and then suddenly Heroku started throwing the same Library not loaded error my way, regardless of comman! Clearly a problem with the gemset, as a little poking around confirmed. But how exactly to isolate and resolve the issue?

For the record, here's the error message:

/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': dlopen(/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/readline.bundle, 9): Library not loaded: /usr/lib/libedit.3.dylib (LoadError)
  Referenced from: /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/readline.bundle
  Reason: image not found - /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.0/readline.bundle
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/heroku-2.30.3/lib/heroku/command/run.rb:1:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/heroku-2.30.3/lib/heroku/command.rb:14:in `block in load'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/heroku-2.30.3/lib/heroku/command.rb:13:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/heroku-2.30.3/lib/heroku/command.rb:13:in `load'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/heroku-2.30.3/lib/heroku/cli.rb:24:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/heroku-2.30.3/bin/heroku:16:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/bin/heroku:19:in `load'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/bin/heroku:19:in `<main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/bin/ruby_noexec_wrapper:14:in `eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/bin/ruby_noexec_wrapper:14:in `<main>'

Turns out everything works fine as along as I use the global gemset, but the problems appear when I use the gemset that Hartl recommends for his tutorial. It appears that Hartl's gemset as used in the
tutorial must conflict with the current Heroku requirements. I'm no expert, so maybe there's another explanation, but this is what I'm going with for the moment.

So I can do a couple of things:
  1. Use the global gemset for the tutorial and see what happens.
  2. Ignore Heroku for now.
  3. ???
There may be other options. I'll sleep on it.

Update (same day):  So maybe there's no problem after all. In trying to follow Heroku's instructions to create an app, I switched to the app's folder (with Hartl's gemset) and tried to run Heroku. No luck. But as long as I can run Heroku outside that folder/gemset, there's no problem. So we'll cross our fingers and soldier on...

Update II (same day): Wouldn't you know it! When trying to run Rails Console ("rails c") the exact same error appeared! Fortunately, after much digging, the following solution emerged:

cd /usr/lib
sudo ln -s libedit.2.dylib libedit.3.dylib

Works like a charm now! (Apparently has to do with the fact that I'm running Snow Leopard instead of Lion. Darn cats. Meow.)

No comments:

Post a Comment