Darwinports is freaking me out!!

Ruby on Rails project logoMan, am I having hard times with Rails and DarwinPorts MacPorts or what? The strangest things keep happening. My Rails install broke down again. Imagine my frustration. I’ve been messing around with it for a few days now. And trust me, nothing wrong with rails. This time it was an incomming update on a support library called gettext. Argh!! On itself nothing wrong with updates, and that stuff breaks because of it, fine. But not all in one week please.

In hindsight the fix was real simple.

  • sudo port uninstall [insert anything starting with rb-]
  • sudo port install rb-rails

Oh and another one if you would want to use rb-sqlite3 on Rails. Install swig before installing the sqlite adapter. And don’t forget, in your database.yml: adapter: sqlite3 Yes, with a three that is.

Just a sidenote: I officially fell in love with TextMate. This editor is soooo cool. Thank you very much MacroMates.

Error installing Rails

Ruby on Rails project logoRecently I re-installed all my DarwinPorts. This included my Ruby and Rails installs. The first time I ever tried installing Rails I used RubyGems installed by DarwinPorts and it worked without a problem. The second time didn’t went so smooth. It appears that the rb-rubygems package of DarwinPorts is FUBAR or something.

For those trying to get Ruby on Rails running on OSX with DarwinPorts/MacPorts: Watch out for this error:

Jeroen:~ jeroen$ sudo gem install rails
Password:
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': \
        no such file to load -- sources (LoadError)
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/remote_installer.rb:462:in \
                `sources'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/remote_installer.rb:472:in \
                `source_index_hash'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/remote_installer.rb:436:in `install'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/gem_commands.rb:258:in `execute'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/gem_commands.rb:220:in `each'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/gem_commands.rb:220:in `execute'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/command.rb:69:in `invoke'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/cmd_manager.rb:117:in `process_args'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/cmd_manager.rb:88:in `run'
        from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/gem_runner.rb:29:in `run'
        from /opt/local/bin/gem:23

I’ve ran into this one. The problem? Quite simple to solve. It seems that the DarwinPorts package sudo port install rb-rubygems should not be used anymore according to some people. Installing rails by using the rubygems installed by DarwinPorts messes things up a little. Try sudo port port install rb-rails instead. It worked for me. Only drawback is, you didn’t install rails with rubygems and you have to remember to install updates and extra gems by using DarwinPorts.

Edit: DarwinPorts is now renamed to MacPorts. An existing DarwinPorts install will transparently update to MacPorts by running “sudo port selfupdate”.

New project assignment, something with Python

Python logo I’ll be taking over a few tasks while a colleague of mine is taking some well deserved R&R. The thing is, I’ve heard it involves Python. *sweet* 😉

That does mean I’ll be scrapping my Ruby experimentation, because I have to brush up my Python skills a bit. It’s been a while since I’ve done any serious Python coding.

If you’re looking into Python too, start here. Oh and, MacOSX 10.4 comes with Python 2.3.5 pre-installed.

First steps with Ruby on Rails

Ruby on Rails project logoAs any self respecting software developer I jumped on the Rails bandwagon too. It will probably not be something I will be using a lot in the near future, but staying informed never hurts.

So of I went to a local bookstore to do some browsing and this resulted in purchasing a book called Agile Web Development with Rails: A Pragmatic Guide (Pragmatic Programmers) by Thomas and Hansson. The upper left corner says “The Pragmatic Programmers”, which resulted in me feeling good about buying this book, since I loved “The Pragmatic Programmer: From Journeyman to Master“.

Agile Web Development with Rails: A Pragmatic Guide (Pragmatic Programmers)The Rails book is very well written. I have not gone through it yet from cover to cover. Right now it’s the book I’m reading at home when I require some privacy. 😉 I find a toilet a place of serenity and quiet contemplation. Or an excellent place to focus one’s complete attention to the contents of a book.

I am running a PowerBook G4 here with OSX. And as the book stated, OSX comes with Ruby pre-installed but requires some tinkering. I opted for the latest Ruby version. So I went with a OpenDarwin Ruby/RubyGems/Rails install. No problem in that area.

The Pragmatic Programmer: From Journeyman to MasterNext up was a database. The Rails book says MySQL is good. So I go with that, although I think an in process DB like SQLite would do just as well for me. Let’s just say it’s been a while since I did a MySQL install. Although it isn’t really necessary as far as I am aware, but I couldn’t get network connectivity to work with MySQL 5. Turned out to be really stupid. Of-course I need to give a user the right on the MySQL instance to actually connect through the network.

Once I got MySQL sorted the fun could begin. Right now I just about finished building the web-shop cart. See, the book uses a simple e-shop as an example. Through the course of about 8 chapters you can build a basic shopping experience. I like this tutorial approach when taking my first steps with a new framework.

MySQL logoIn the end I guess I will get a pretty decent overview of Rails. And while I do get the feeling Rails can be a huge timesaver, it does still feel awkward to me that you should do it the Rails way or preferably not with Rails at all. The whole programming by sensible default is still a bit jarring. I guess because I am more used to rocket science style over-engineered Java systems. Not the most effective use of Java in my opinion. But hey, I’m no software architect yet, so why should anyone listen to my opinion. 😉 Also I can’t quite get that Ruby syntax in my fingers yet. Perhaps I should look into buying the pickaxe book too.

I am very curious about where Ruby on Rails will be in a few years. Although many people claim that it’s not ready for prime-time yet, that it’s still a technology too new for “enterprise implementations”. (That’s one term for your BS-bingo list.) I think that Ruby on Rails may actually be further along and actually quite capable and ready for prime-time. I guess time will tell. It is an interesting framework and takes some refreshing approaches, so even when you are not going to use it this or next year do take a peak at it. Most likely some of the concepts of Ruby on Rails will actually be useful for your regular dayjob.

Oh and about the book, yes it is an excellent read on Ruby on Rails if you like a tutorial style read.