Monthly Archives: December 2007

Building Ruby 1.9.0 on an Apple Mac

I decided to start playing around with the latest Ruby, 1.9.0, which was released on Christmas Day.  I am on a MacBook Pro running OSX Tiger 10.4.11.

I previously blogged about what to do with Ruby 1.9 to get up-to-speed. Anyone using Ruby today probably shouldn’t be considering overwriting their Ruby 1.8.6 installation if they do any real coding or have an existing code base. Many of the gems and libraries you use may not work with 1.9, Rails 2.0.2 for one does not.

Getting Started

The first thing I did was download the Ruby 1.9 source from Ruby-Lang, ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.0-0.tar.gz. I copied the contents of this archive to a folder in my home directory called Source (/Users/rbazinet/Source). This way I keep all of my downloaded source organized and easy to manage.

Opening up a Terminal window and changing to that directory will get things started. Now to setup the build to not overwrite my installed version 1.8.6 of Ruby, I created a directory called ruby19 in my home directory.

$ autoconf
$ ./configure --prefix=/Users/rbazinet/ruby19
$ make

Of course nothing always works as planned. During the build I received the following error:

compiling readlinegcc -I. -I../../.ext/include/i686-darwin8.11.1 -I../.././include -I../.././ext/readline -DRUBY_EXTCONF_H=\"extconf.h\"    -fno-common -g -O2 -pipe -fno-common   -o readline.o -c readline.c
readline.c: In function 'filename_completion_proc_call':
readline.c:659: error: 'filename_completion_function' undeclared (first use in this function)
readline.c:659: error: (Each undeclared identifier is reported only once
readline.c:659: error: for each function it appears in.)
readline.c:659: warning: assignment makes pointer from integer without a cast
readline.c: In function 'username_completion_proc_call':
readline.c:684: error: 'username_completion_function' undeclared (first use in this function)
readline.c:684: warning: assignment makes pointer from integer without a cast
make[1]: *** [readline.o] Error 1
make: *** [all] Error 1

It appears readline is the problem here and needs to be updated. After a bit of searching around the net I can across some information about this and determine readline needs to be updated to readline 5.2.

Readline can be downloaded from Gnu.org. I created a directory in my standard Source folder called readline-5.2 and then performed a build:

$ cd /User/rbazinet/Source/readline-5.2
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

Now with Readline 5.2 installed I tried the Ruby 1.9 build again, this time indicating the location of my new Readline installation:

$ autoconf
$ ./configure --prefix=/Users/rbazinet/ruby19 --with-readline-dir=/usr/local
$ make
$ make install

Changing to our new Ruby 1.9 installation directory:

$ cd /Users/rbazinet/ruby19/bin
$ ./ruby -v
ruby 1.9.0 (2007-12-25 revision 14709) [i686-darwin8.11.1]
$

Success!

We could add our new ruby/bin to path if we wanted, to make it a big easier to test, but for now this works.  I am running Tiger so I don’t know if this same procedure works on Leopard.  If someone can confirm if this works or can comment on how to build Ruby 1.9 on Leopard, I will update this post to reflect what is needed to be done.

Technorati Tags: ,,

Ruby 1.9 Released – Should you use it today?

Ruby Logo

Ruby 1.9 was released on Christmas, announced on the Ruby web site. Matz made the announcement we all expected, as Matz seems to enjoy giving all the Rubyists a nice Christmas present.

Many developers probably were anxious for the release and wanted to download it, get it setup and start using their Ruby or Rails applications with some new found speed improvements. Anyone who has been around the computer industry for any amount of time knows it is rarely easy just to take a new release of a programming language and just use it with existing code or framework.

Dave Thomas has some nice insight on the topic of using Ruby 1.9 and whether it is right for you.

The Good:

  • Performance: this new Ruby runs on the new YARV virtual machine. For most compute-intensive applications, you’ll see significant speed improvements.
  • Support for string encodings and transcoding. Every string in Ruby can now have an associated encoding (ASCII, UTF-8, SJIS, and so on). You can transcode the contents of a string (for example converting ISO-8859-1 to UTF-8).
  • Integrated RubyGems and rake
  • Cool new goodies such as Fibers

The Bad:

  • This is a development release, not a production release. It has known bugs, and there’ll be more to come.
  • It contains several incompatible changes (block parameters are now block-local, String is no longer Enumerable, “cat”[1] now returns “a”, rather than 65)
  • It is more rigorous that 1.8 when it comes to detecting invalid code. For example, 1.8 accepts /[^\x00-\xa0]/u, while 1.9 complains of invalid multibyte escapes

Some of the things Rails developers expect today is that things normally just work and we take a lot for granted. Many of the existing gems and libraries do not work with Ruby 1.9, this includes Rails 2.0.2. Users have reported creating a new Rails application does not work property.

What’s the purpose of Ruby 1.9 then?

Well, it’s a development release so how about use it for development? This means developers who have created gems or libraries for Ruby should be taking advantage of this early release and get their products to work with 1.9.

It is also made available for hard-core Ruby developers to learn what’s new and how to use the new features, to play around with now. This does not mean you should be using it for production code, there are known bugs and there will be more found.

Users should install Ruby 1.9 as a secondary Ruby install, not an install over the top of your production Ruby 1.8.x or whatever. Dave Thomas gives a nice tutorial on the subject:

$ autoconf
$ ./configure --prefix=/Users/dave/ruby19
$ make
$ make install

Then, I just add /Users/dave/ruby19/bin to my path, and I'm using my nicely sandboxed version of Ruby 1.9.

$ PATH=/Users/dave/ruby19/bin:$PATH$ ruby -v
ruby 1.9.0 (2007-12-26 revision 0) [i686-darwin8.11.1]

This method will give you a sandbox or Ruby 1.9 to write code with and explore.

So, should it be used today?

The answer is yes and no. Yes, so you can play around with it, get to know it and update your libraries or gems if you maintain any. The other side of the argument is that you should not expect to use it for production code, it’s not meant for that today.

Ruby has come a long way and the future is bright. The performance improvements alone is reason enough to want to get it and learn it.

Technorati Tags: ,

Instant Rails 2.0 Released on RubyForge

I have been working hard on getting the latest and greatest components of Instant Rails 2.0 put together into a  coherent release to RubyForge.  It has been a bit more time consuming bringing it all together, learning the components of the project, learning more about Subversion than I knew already as well as how the whole process of working with RubyForge really happens. 

Being part of the open source community feels good and it feels good giving back to something I am passionate about.

It was very smooth for the most part, but trying not to mess up what already worked is what I am hoping for, so since this is my first work on an open source project from a commiter’s role, please be kind.  If there issues please submit them to the Instant Rails list or as a comment on this blog post.

Instant Rails 2.0 includes:
  • Ruby 1.8.6 Patch Level 111 with tons of bug fixes and new updated gems
  • Ruby on Rails 2.0.2
  • RubyGems 1.0.1
  • Rake 0.8.0
  • Mongrel 1.1.2
  • SQLite3

SQLite3 is included in this release since Rails 2.0.2 uses it by default.  Users should notice the Cookbook example uses the latest Rails 2.0.2 changes and has been updated to use SQLite3.

Instant Rails 2.0 can be downloaded from RubyForge now, please take a look at the Release Notes to see all the updates.

I will have some additional updates to the project over the next weeks.  I plan to post want I am going to update and hopefully I will receive the kind of feedback my readers have been providing.  Thank you all!

My David Heinemeier Hansson Rails 2.0 Interview up on InfoQ

I had the opportunity to interview David Heinemeier Hansson, Ruby on Rails creator,  recently for InfoQ and it went live today.  I was very impressed with David’s willingness to talk to me given the interview occurred right after the Rails 2.0 release.  I am sure I was not the only one pursuing him for an interview at the time.

You can check out the full interview, Talking Rails 2.0 with David Heinemeier Hansson, at InfoQ.

Setting up SQLite3 for Ruby on Rails Development

UPDATE: Thanks to an astute reader, it seems to have full SQLite3 support on Windows you need to add the SQLite3.dll and the SQLite3.def files also in your path.  I put these in my ruby/bin folder, which is where they will be in the Instant Rails release coming up.

The release of Ruby on Rails 2.0.2 made some fairly significant changes in the default database for Rails applications.  The default, and standard, database has always been MySql but the Rails team felt it easier for development to use SQLite3 and make it the new default.

Setting up SQLite3 is pretty straight forward both on Windows and the Mac OSX, both Tiger and Leopard come with SQLite3 already installed so that makes the Mac one up on Windows.  My Tiger installation had SQLite3 v3.13 installed on it so I wanted to make sure I had the latest at the time of this writing and put 3.5.4 on it.

Installing on Windows

The installation on Windows was really straight forward.  The main thing is to download the pre-compiled version of SQLite3 3.5.4 from the SQLite web site, unzip it and copy the single sqlite3.exe to my ruby/bin directory.

Now that SQLite3 is installed, just install the gem:

gem install sqlite3-ruby

And that’s it.

Installing/Updating on the Apple Mac OSX

Upgrading my Rails installation was a breeze on my MacBook Pro, after upgrading to RubyGems 1.0 the Rails 2.0.2 install went through without a hitch.  The only real concern I had about upgrading to Rails 2.0.2 on the Mac was the fact the default database for 2.0.2 is SQLite3 and I had an old version.  I feel a bit indifferent about installing over versions of software installed by Apple in the event it is used by something and I break it.  I am pretty new to the Mac and fixing an issue like this can sometimes be intimidating.

I found an older version of SQLite3, here:

/usr/local/bin/sqlite3

There are several ways to update software like this on the Mac and using MacPorts seems to be a popular way to do it, but I chose to install from source.   I have a Source directory in my home folder on my Mac and I simply start everything from there.  So, to install I did the following:

$ curl -O http://www.sqlite.org/sqlite-3.5.4.tar.gz
$ tar xzf sqlite-3.5.4.tar.gz
$ cd sqlite-3.5.4
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

After working with Windows systems for most of my professional career I chuckle at how cryptic the commands are in Unix-like environments.  Maybe this is to keep the barrier to entry high.

Using the “which sqlite3” command should reveal the same location as the original SQLite3 installation.  If you actually type in “sqlite3” you enter the command mode of SQLite3 and should see the new 3.5.4 version.

The last step to is to install the Ruby driver for SQLite3, accomplished with:

$ sudo gem install sqlite3-ruby

This installed without any problems and was good to go with using SQLite3 on my Mac Rails 2.0.2 installation.  It’s funny though, the Windows installation was very easy and the Mac install took a bit of work that was not particularly obvious.  I thought the Mac was supposed to be so much easier than the PC?  Isn’t this what the Apple ads try to get us to believe?  I guess Apple just has better marketing.

Technorati Tags: ,,,

RubyGems 1.0 Released, Helps Windows Developers

UPDATE: Make that RubyGems 1.0.1, released tonight.

The great folks at the RubyGems project have released RubyGems 1.0.  This release fixes a bunch of issues, including some important ones for Windows developers.  Updates include:

Major New Features Include:

  • RubyGems warns about various problems with gemspecs during gem building
  • More-consistent versioning for the RubyGems software

Other Changes Include:

  • Fixed various bugs and problems with installing gems on Windows
  • Fixed using gem server for installing gems
  • Various operations are even more verbose with—verbose
  • Built gems are now backwards compatible with 0.9.4
  • Improved detection of RUBYOPT loading rubygems
  • ruby setup.rb now has a—help option
  • Gem::Specification#bindir is now respected on installation
  • Executable stubs can now be installed to match ruby’s name, so if ruby is installed as ‘ruby18’, foo_exec will be installed as ‘foo_exec18’
  • gem unpack can now unpack into a specific directory with—target
  • OpenSSL is no longer required by default

Deprecations and Deletions:

  • Kernel#require_gem has been removed
  • Executables without a shebang will not be wrapped in a future version, this may cause such executables to fail to operate on installation
  • Gem::Platform constants other than RUBY and CURRENT have been removed
  • Gem::RemoteInstaller was removed
  • Gem::Specification#test_suite_file and #test_suite_file= are deprecated in favor of #test_file and #test_file=
  • Gem::Specification#autorequire= has been deprecated
  • Time::today will be removed in a future version

It’s pretty simple to update your current RubyGems installation, simply type:

gem update --system

The upcoming release of Instant Rails 2.0 will include this new version of RubyGems, primarily because of the issues 0.95 users experienced on Windows.  Please read the official announcement on this RubyGems release which will help with other ways to update or install RubyGems on your system.

Technorati Tags: ,

links for 2007-12-20

  • A cool idea for hosting your Rails applications. You can even edit your code on-line.
    (tags: rails hosting)
  • A great utility for managing your gems, especially when going to production.
    (tags: rails gems)
  • Nice plugin for manager database configuration in a .rb file. This allows switching between databases pretty easily.
    (tags: plugin rails)

What’s Coming in Instant Rails 2.0 and Beyond – The Road Map

Since I took over the Instant Rails project a short time ago I have been working on learning the structure of the project and figuring out what to put in the next release and beyond. The next release will be Instant Rails 2.0. The reason for the jump is primarily because Ruby on Rails itself has jumped to be 2.0, so why not keep it parallel.

Instant Rails 1.7 Components

The current version includes the following core components:

It contains the following sample applications:

And a few ancillary applications which some of Instant Rails depends on:

Instant Rails 2.0 Components

The current version includes the following core components:

It contains the following sample applications:

And a few ancillary applications which some of Instant Rails depends on:

Instant Rails 2.0 and Beyond

I have chatted with several people who would like to see various features and components upgraded or added to the project. I can’t see with any certainty what components might be added but I can say I will do my best to add what people want but remain keeping the project light and stable.

Some of the items users wanted to see are:

  • PHP 5
  • SQL Server Support
  • IIS Support
  • SubVersion
  • SQLite3

Developers should take a look at the release notes for Ruby 1.8.6-26, which includes updates which provide support for running Rails applications under IIS7. The important components are FastCGI and ruby-fcgi.

It should also be noted that Rails 2.0.2 uses SQLite3 as its default database and therefore when creating Rails applications under Instant Rails, the command looks like this:

rails -d mysql myapp

Should SQLite3 be included in the next release of Instant Rails now that SQLite3 is the default database? I tend to think this would be the right thing to do but features like phpMyAdmin become a bit irrelevant being a MySQL tool. I have found a tool called SQLiteManager which is a web-based admin tool for SQLite3 databases. Anyone familiar with it? It appears to be a bit dated.

I am planning at looking to upgrade to Ruby 1.9 when available as well as at upgrading to the latest version of MySQL and Apache, but these will have to wait a bit since they work great just the way they are today. The sample Typo 2.6 installation could use an upgrade to Typo 4.x as well.

I would like to continue to hear what people would like to see, please email me at [rbazinet] at [gmail.com] or reply to this post.

Technorati Tags: ,

links for 2007-12-16

Instant Rails Lives On

logo50

I have been a long-time user of Instant Rails to write Ruby on Rails applications on Windows.   What I like most about Instant Rails is its level of isolation, where nothing is installed on my local computer as a service or anything permanent.  I can just take it with me and run it anywhere.

A short time ago Curt Hibbs, the founder of the Instant Rails project on Rubyforge, decided he didn’t have the time to continue the project to the level it deserved.  He announced the project would not longer be updatee and users should look to another Ruby stack on Windows, named BitNami RubyStack

After trying BitNami I came away feeling like I had stepped back to something not as polished as Instant Rails.  I have no ill feeling about Bitnami, I hope they do very well.  I have been spoiled by the way Instant Rails runs isolated along with its nice user interface to control services and my Rails applications.

 

image

 

I decided to contact Curt and see what the story was with closing down the project and if I could do anything to help maintain it.  Curt explained he was simply too busy with work and real life to maintain the project any longer and it was as simple as that.  I thought about it a bit and offered to take the project over continue with this legacy.  Curt was happy to have someone keep the project going.

So, now what?

Immediate Plans

This is my first foray into an open source project so please be patient.  Anyone with advice on maintaining an open source project, it would be appreciated.  For the short term my goals are not lofty, I plan on:

  • Learning the layout of the Instant Rails project
  • Inventory what is currently part of the project
  • Understand how the project was administered so I can successfully manage to continue the project

Short-term Plans

In the next few weeks I want to be able to get a release out to RubyForge.  I would like to at least provide and update to the following:

  • Ruby on Rails 2.0.1, or newer if bugs are patched between now and then
  • Ruby 1.8.6 Patch Level 111

Longer-term Plans

I have used Instant Rails and love how it works.  I am not going to make any large changes with the project, I want to keep the functionality the way it is.  Curt has done a great job and there is no need to change for the sake of change.

I plan to make some updates to some of the packages to get them up-to-date beyond the ones above:

  • RubyGems
  • MySQL
  • Mongrel
  • Rake
  • Ruby 1.9

Of course I will fix any bugs I can along the way.

I have been asked about adding some things to the current build such as Capistrano 2.1 among some others. What would users like to see?   I can’t really add any and all gems to releases, it has to be by consensus.  As always users can just add gems themselves and customize as much as they want.

I will be posting updates here as things progress and I get other ideas or come to a fork in the road and need feedback.  Please come here for informational updates on Instant Rails.  Release updates will continue to be in the RubyForge project page.

 

Technorati Tags: ,