Thursday, August 23, 2012

A Tale of Two Annoyances: The Rails Tutorial Continued

Annoyance 1:

Site works fine on my computer. After moving to Heroku, no pages could be accessed except the home page.

Turns out they were invisible because they were not in the public directory, and I needed to do a bit more configuring to make them accessible.


Annoyance 2:

The new home page I created, when loaded, defaulted to the old one.

Even after I deleted the old one.

Even when inspecting the source code showed the new page's source code!

Deleting the cache solved that one.

Tuesday, August 21, 2012

ExecJS::ProgramError

... is never a nice thing to hear/see. On chapter 2 of Hartl's tutorial, when I was supposed to see a nice little page like this:

Listing users

Name Email



New User
I instead saw the above error and a bunch of information that would probably be useful to somebody who had been coding since I was in diapers.


After a brief websearch, I found the answer here.

I've noticed a few people saying that they prefer the "Agile" book to Hartl's, but I'm sticking with this for now because I'm still learning a ton and haven't encountered any insolvable errors yet.

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.)

Monday, August 20, 2012

Ruby on Rails, Here We Come!

So, jumping on the Rails shtick, using ruby.railstutorial.org as my guide to getting my feet wet (and hopefully waist and even head). Installation has been remarkably painless thus far. JewelBox won't work yet—just crashes on launch—but we'll worry about that later.

At the moment, the biggest headache I encountered was when I followed the instructions for updating rvm. I got the error message:

Upgrading the RVM installation in /usr/local/rvm/
cp: /usr/local/share/man/man1/rvm.1: Permission denied


    Please run the installer using rvmsudo to fix file permissions

stat: /usr/local/share/man/man1/rvm.1: stat: No such file or directory
chown: /usr/local/share/man/man1/rvm.1: No such file or directory
cp: /usr/local/share/man/man1/rvm.1.gz: Permission denied


    Please run the installer using rvmsudo to fix file permissions

stat: /usr/local/share/man/man1/rvm.1.gz: stat: No such file or directory
chown: /usr/local/share/man/man1/rvm.1.gz: No such file or directory
    RVM PATH line found in /Users/slittle2/.bashrc /Users/slittle2/.zshrc.
    RVM sourcing line found in /Users/slittle2/.bash_profile /Users/slittle2/.zlogin.

Right.

Anyway, typing rvmsudo install etc. did no good. Just more error messages. And then I found this helpful little note:

 rvmsudo is equivalent of sudo, it does not append rvm to the command, you should run: rvmsudo rvm get head

Ah, of course! I ran the command, looks like it executed just fine!

On with the Rails!