Archive for the ‘ Ruby ’ Category

First look at the RHEL 6

Red Hat have put out a public beta of the forth coming version of RHEL. The package list looks quite promising, with the improvement on virtualisation, storage and cluster suite improvements, you can easily tell that it’s target to the enterprise market and follows the trends.

For every new version of RHEL coming out, new software packages is added to the distribution, some old softwares get removed, and most of the software packages get updated version.

The most important changes are all system-config-* tools are gone now. The ext4 file system is the default, instead of ext3 in RHEL5. Python get updated from version 2.4 to 2.6 but Ruby is still in version 1.8.6, only a small minor update from version 1.8.5 in RHEL5. Since RHEL 6 only included in version 1.8.6, it will not even run Rails 3. Rails 3 required at least ruby 1.8.7, or ruby 1.9.2 to run, it’s a shame that Red Hat only include a old version of ruby in their RHEL6, but you can always install REE or compile from source by yourself.

Maybe you can give Ubuntu 10.04 LTS a try, Ubuntu 10.04 LTS also include some interesting feature including MySQL 5.1, python 2.6, Ubuntu Enterprise Cloud, and Ubuntu One File Syncing. Ubuntu 10.04 LTS is schedule to release on 29 April 2010.

Installing Rails 3 beta 2 using rvm

Rails 3 beta 2 was released at April 1. From the blog post at Riding Rails, it seems that this beta 2 break lots of things.

Note that Ruby 1.8.7 p248 and p249 has marshaling bugs that crash both Rails 2.3.x and Rails 3.0.0. Ruby 1.9.1 outright segfaults on Rails 3.0.0, so if you want to use Rails 3 with 1.9.x, jump on 1.9.2 trunk for smooth sailing.

Both Ruby 1.8.7 p248 and p249 crashed and Ruby 1.9.1 have segfaults problem. So it’s time to move on to Ruby 1.9.2. Ruby 1.9.2 is still in the development phase but it will be ready in 4 months. The scheduled release date is 31 July 2010. Let’s install rvm with ruby 1.9.2 to try out the newly released Rails 3 beta 2.

Install rvm

$ mkdir -p ~/.rvm/src && cd ~/.rvm/src && rm -rf ./rvm/ && git clone
git://github.com/wayneeseguin/rvm.git && cd rvm && ./install

The installation will take a while, and after rvm is installed, you’ll need to edit your .bashrc and .bash_profile. Append the following at the end of your .bashrc/.bash_profile:

if[[ -s /Users/stevew/.rvm/scripts/rvm ]];
    then source /Users/stevew/.rvm/scripts/rvm;
fi

Install Ruby 1.9.2 head, remember to install the head of ruby 1.9.2 branch, not the preview1 because ruby 1.9.2 preview1 doesn’t work with tzinfo gem, you will have problem like this

.rvm/gems/ruby-1.9.2-preview1/gems/tzinfo-0.3.18/lib/
tzinfo/timezone.rb:108:in `rescue in get’: protected method 
`setup’ called for #<tzinfo::datatimezone:0x000000024b7cb8> 
(TZInfo::InvalidTimezoneIdentifier)
$ rvm install 1.9.2-head

It will take a while to download and compile the ruby 1.9.2. once completed you can run the ruby command to verify the ruby version.

$ rvm 1.9.2-head
$ ruby -v
ruby 1.9.2dev (2010-04-07 trunk 27247) [x86_64-darwin10.3.0]

Set the default ruby version to ruby 1.9.2-head

$ rvm 1.9.2-head --deafult

Install Rails3 beta2, you don’t need to use sudo here to install gem beacuse all gems will install in your local home directory

$ gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
$ gem install rails --pre

Install sqlite/mysql gems for rails

$ gem install sqlite3-ruby
$ gem install mysql -- --with-mysql-dir=/usr/local/mysql

Just create a new project as usual and that’s it. you are now ready to try out Rails 3 beta 2.

Generating rails app in previous version after rails 3.0 beta

Rails 3.0 beta was released 2 weeks ago, rails 3 has many improvement over previous version of rails. It’s also the first version that after rails and merb merged. Truth be told, rails 3 beta has changed a lot since version 2.3.5. Many gems has not supported in rails 3 beta yet, e.g. RSpec and Cucumber. It’s hard to move your existing project to Rails 3 without the support of required gem.

As a Rails programmer, you should already grab a copy of Rails 3 beta to learn the future development of Rails. I have already installed Rails 3 beta on my Mac. Rails 3 run smoothly on new project, except RSpec and Cucumber not supported. I was able to work on existing project on Rails 2.3.5 after installed Rails 3 beta, nothing weird has happened except when I want to start a new Rails 2.3.5 project.

MyMac:work stevew$ rails _2.3.5_ rails2project
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:777:in `report_activate_error': 
RubyGem version error: railties(3.0.0.beta not = 2.3.5) (Gem::LoadError)
	from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:211:in `activate'
	from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:1056:in `gem'
	from /usr/local/bin/rails3:18:in `'

What’s wrong with my rails 2.3.5? It turns out is the problem of railties gem installed by rails 3 beta, railties gem doesn’t exists before rails 3 beta, so it complain railties version 2.3.5 not found. I start google around, and I am not alone, there is a few people out there have the same problem, and I finally found the temporary solution in the web, but I forget the link. So here is the soltion:

edit your rails script, my rails is installed at /usr/local/bin/rails, change the last 2 line to

#gem 'railties', version
#load Gem.bin_path('railties', 'rails', version)
 
gemname = 'railties'
gemname = 'rails' if version.split(".").first.to_i == 2
gem gemname, version
load Gem.bin_path(gemname, 'rails', version)

Basically, we only replace the gem name of railties to rails if the version params start with 2.

Rails 2.3.5 Released

A new version of Rails is released, Rails 2.3.5 fixed the incompatibility issues with Ruby 1.9 found in Rails 2.3.4, with Rails 2.3.5, you are not required to patch Rails if you develop your webapp using Ruby 1.9, and this release contains several bug fixes and 1 security fix. As usual, test your webapp before you upgrade and deploy your webapp in production.

Ruby Enterprise Edition 1.8.7

The folks at Phusion had put out a new version of Ruby Enterprise Edition 1.8.7, 1.8.7 is more compatible to ruby 1.9 than 1.8.6, also the rubygems had upgraded to version 1.3.5.  This version has been beta tested by the Twitter guys, 37signals guys, and those people at Novell. Evan Weaver reported significant improvements in Twitter’s throughput after having switched to this REE release.

This is the first REE target to compatible with ruby 1.8.7, the exact version is ruby 1.8.7-p174, all previous REE versions are target to compatible with ruby 1.8.6. As the development of Rails 3.0 is going well, we will need a new ruby version for the upcoming release. Rails 3.0 required at least ruby version 1.8.7, so this is a move to ruby 1.8.7. Mac OSX snow leopard comes with ruby 1.8.7 out of the box. Most version of Linux also shipped with ruby 1.8.7, but not quite true for RHEL.

RHEL5 comes with ruby 1.8.5, that’s ok for a 2 year old distribution, but for the upcoming RHEL6, which probably based on fedora 10/11, which shipped with ruby 1.8.6. This version of REE is time saver for those people on RHEL. Come on Redhat guys, give us a more updated version of Ruby please!

If you planned to install this version of REE on snow leopard, make sure you run the installer with --no-tcmalloc switch.

P.S. we will probably got an update version of Agile Web Development with Rails around Christmas, and all those examples in version 4 of the pickaxe book will be working on Ruby 1.9.2. If I have a new Rails project to start, I’ll probably pick version 1.9.

Page 1 of 212