Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

July 22, 2008

Setting Up Rails Development Environment on Ubuntu GNU/Linux

Filed under: Ruby/Rails, Ubuntu — tabrez @ 7:38 pm

This is an adaptation to Ubuntu GNU/Linux platform of my previous post which was meant for the Windows platform: Setting Up Rails Development Environment on Windows Vista/XP

I can think of two different ways in which you might want to set up a development environment for Ruby on Rails on a GNU/Linux machine. One is to download everything outside of the package manager of your distribution i.e. build everything from the source. I am going to cover the second, easier way: how to setup Rails on a Debian/Ubuntu machine using its package manager for the most part. I show below how to setup Ruby, RubyGems, Rails, Mongrel, MySQL, and Subversion as part of the development stack.

Installing Ruby:

If not already installed, install the build-essential package first:

# sudo aptitude install build-essential

Then install the Ruby and related packages:

# sudo aptitude install ruby irb ri rdoc rake libopenssl-ruby libsqlite3-ruby ruby1.8-dev

Installing Rubygems

Though it is possible to install Rubygems using the Ubuntu package manager, not only will you get an old version of rubygems if you do so, it also may not be compatible with the latest version of rails. I strongly recommend you download the source code package of the latest version of rubygems and install it using its setup script:

# cd $HOME
# wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
# tar xvzf rubygems-1.2.0.tgz && cd rubygems-1.2.0
# sudo ruby setup.rb

Debian purists may frown at installing packages all over the system directories outside of control of the package manager. See Debian’s position on Rubygems. [via - RailsOnUbuntu]
Remember to download the latest version of rubygems available(currently 1.2.0). You can remove the downloaded tgz archive and the extracted directory after the installation is finished.

#cd $HOME
# rm -r rubygems-1.2.0.tgz rubygems-1.2.0

If Ubuntu complains that the ‘gem’ command is not found, you may have to create a symbolic link like this:

# sudo ln /usr/bin/gem1.8 /usr/bin/gem

You can update the rubygems package by running the following command:

# sudo gem update ––system

Installing Rails

The final step is to install the Rails gem package itself.

# sudo gem install rails

This will install the latest Rails version on your Ubuntu GNU/Linux. If you ever want to update Rails in the future, just run the following command:

# sudo gem update rails

You can update the other packages using Ubuntu’s package management tools(aptitude) since that is how you installed those packages in the first place.

The basic Rails development environment is now installed on your system and you can skip the rest of the post if you are happy with WEBrick as the web server, SQLite as the database server and your favourite text editor/IDE that may be already installed on your system. The following instructions cover installing an alternate web server called Mongrel; MySQL database server and its GUI tools; and Subversion.

Installing Mongrel

Installing the Rails gem also installs the WEBrick web server which is ideally suited for development purposes. Another much recommended web server for Rails development as well as production environment is the Mongrel web server. To install the Mongrel web server, run the following gem command:

# sudo aptitude install mongrel

After installing Mongrel, Rails automatically starts the Mongrel instead of WEBrick web server when you run the Rails applications in development mode. (Refer to Mongrel documentation to know more about runing Rails applications under Mongrel in production mode.)

Installing MySQL

This step covers the installation of MySQL database server and its GUI tools. Skip this step if you want to use some other database server. Run the following command to install the required mysql packages:

# sudo aptitude install mysql-server mysql-admin mysql-query-browser

One important step during the configuration process is to select a root password(you will need to enter it in the database.yml configuration file of your Rails application).

Installing Subversion

Finally, install your favourite revision control software - CVS, Subversion, git etc. You can install subversion in this way:

# sudo aptitude install subversion

Now you can create/checkout Rails applications, edit the files using your favourite text editor/IDE and run it under Mongrel. In future, I will try to write about developing Rails applications using integrated development environments like Eclipse and NetBeans.


If you want to receive future posts by email, enter your email address here:

Related Posts:

July 14, 2008

Installing Grails in Ubuntu GNU/Linux Using Package Manager

Filed under: GNU/Linux, Groovy/Grails, Ubuntu — tabrez @ 3:21 pm

In my previous post I talked about setting up Grails development environment in GNU/Linux distributions by manually downloading the packages and configuring the environment variables. The main advantage of this method is that you can work with the latest versions of the Groovy and Grails packages available, and in fact, you can work with more than one version of these software at the same time: just point your environment variables to different locations. The procedure is also more or less independent of a particular GNU/Linux distribution.

An easier, alternative way to install Groovy and Grails packages is to use the package management system of your favourite GNU/Linux distribution. The trade-off is that you have to accept the version of the packages that are available in your distribution’s repositories(apt-get) or you may have to compromise with the stability of your system(dpkg). Below I am documenting the procedure to install Grails development environment using package manager tools in Ubuntu 8.04(Hardy Heron).

Installing Sun JDK 6 in Ubuntu 8.04 Using apt-get/aptitude

In Debian/Ubuntu based operating systems installing new packages is as simple as running aptitude command with the package name.

# sudo aptitude install sun-java6-jdk

You also need to set JAVA_HOME environment variable in your preferred profile file(/etc/profile, $HOME/.profile or /etc/environment):

JAVA_HOME=/usr/lib/jvm/java-6-sun

Refer to the first step of previous post in my Grails series if you need more help.

Installing Groovy in Ubuntu 8.04 Using apt-get/aptitude

To install Groovy and its dependency packages, run the following command in a command shell:

# sudo aptitude install groovy

You can also install Groovy from Synaptic Package Manager, simply search for package name called “groovy” in it. But have a look at the version number!

Synaptic Package Manager shows an old version of Groovy package in Ubuntu 8.04 package repository

See what I mean? The latest stable version of Groovy is 1.5.6 though I would recommend using the 1.6 beta 1.

Installing Groovy in Ubuntu 8.04 Using GDebi

If you don’t mind picking up a deb file from a third-party source, Groovy download page has Debian/Ubuntu packages for both 1.5.6 stable version and 1.6 beta 1 version.

Groovy latest stable version for Debian/Ubuntu family of GNU/Linux distributions available as a deb package.

When you download the Ubuntu deb binary from this page Ubuntu will automatically open it using GDebi and install it for you.

Download the Groovy deb package from its download page and install it with GDebi application.

Installing Groovy in Ubuntu 8.04 Using dpkg

You can also save the deb file on your computer and install it from the command shell using the dpkg tool:

# sudo dpkg -i <name-of-the-downloaded-deb-file>

Installing Grails in Ubuntu 8.04 Using apt-get/aptitude

Unfortunately there is no Grails package in Ubuntu official repositories yet. You can try any unofficial repositories for Grails available on the Internet but only if you trust them. An old repository meant for installing Grails 1.0 RC2 on Ubuntu Gutsy was posted on Ubuntu Forums by prach. Have a look at it just as an example, I don’t recommend actually using it. I don’t know of a similar repository for more recent versions of Grails. So better option will be to install the latest deb package of Grails using GDebi or dpkg tools; see the next step.

Installing Grails in Ubuntu 8.04 Using GDebi

You can follow the above procedure(Step 2(b)) used for Groovy to install Grails too, by downloading its deb package from Grails’s download page.

Download the Groovy deb package from its download page and install it with GDebi application.

Then choose to open the package with GDebi installer.

Download the Grails deb package from its download page and install it with GDebi application.

Installing Grails in Ubuntu 8.04 Using dpkg

You can also save the deb file on your computer and install it from the command shell using the dpkg tool:

# sudo dpkg -i <name-of-the-downloaded-deb-file>
You can now go to the post where I show how to create a basic “Hello, World” Grails application to test your Grails configuration. (You can ignore the first step of that post.)

Summary:
To summarize, you can install Sun JDK, Groovy and Grails packages in Debian/Ubuntu family of distributions using simple commands, like this:

# sudo aptitude install sun-java6-jdk
# sudo echo ‘JAVA_HOME=/usr/lib/jvm/java-6-sun’ >> /etc/profile
# wget http://dist.codehaus.org/groovy/distributions/installers/deb/groovy-1.6-beta-1.deb
# sudo dpkg -i groovy-1.6-beta-1.deb
# wget http://ant-deb-task.googlecode.com/files/grails_1.0.3-1_all.deb
# sudo dpkg -i grails_1.0.3-1_all.deb

You can use similar commands/tools for other GNU/Linux distributions, like yum in Fedora, yast in openSUSE, emerge in Gentoo, etc. All the above download links point to the latest versions at the time of this writing, so remember to change them appropriately when updated versions are released.


If you want to receive future posts by email, enter your email address here:

Related Posts:

October 31, 2007

Installing C#/Mono(.NET)/MonoDevelop/XSP in Ubuntu Gutsy Gibbon(7.10)

Filed under: GNU/Linux, Mono, Ubuntu — tabrez @ 12:33 pm

The reason for not updating the old post that explained how to install C#/Mono/MonoDevelop/XSP packages in Ubuntu Dapper Drake is that the procedure remains pretty much the same for Ubuntu Feisty Fawn as well as the recently released Ubuntu Gutsy Gibbon distributions(but now you get the newer versions of those packages installed, of course). You can just go through that longer post and probably make one or two changes here and there to get everything running under Feisty/Gutsy too.

Do note that Ubuntu Gutsy Gibbon supports installing the more recent stable versions of Mono(1.2.4) and MonoDevelop(1.4) right from its package manager than any other distribution(AFAIK). Mono 1.2.5 is released but it is not available even in Gutsy. All other distribution either install the older versions of Mono and MonoDevelop or make you compile these packages from the sources(which is a good idea even on Gutsy if you want Mono 1.2.5 or some bleeding-edge version of MonoDevelop).

Below is a command running which will get most of the packages related to Mono and MonoDevelop installed on your Ubuntu Gutsy Gibbon(7.10) operating system. The only changes you can notice here are the missing mono-gac package(as it comes installed by default in Gutsy) and the addition of monodevelop-query and libnunit-doc packages. Drop the packages that you don’t want from the command line, and remember that dependencies will be automatically pulled by apt if you accidentally drop any needed packages, so don’t worry too much about it.

sh# sudo aptitude install mono mono-gmcs mono-utils monodevelop monodoc mono-xsp monodoc-http monodoc-ipod-manual monodoc-njb-manual monodoc-nunit-manual monodoc-gtk2.0-manual monodoc-gecko2.0-manual monodoc-ipod-manual monodoc-njb-manual monodoc-nunit-manual monodoc-gecko2.0-manual mono-xsp2 monodevelop-java libnunit-doc monodevelop-nunit monodevelop-versioncontrol monodevelop-query

A lot has changed in the Mono world in the past year but I will leave it up to you to explore the changes according to what version you are interested in. Here are some links to get you started:

What’s new in MonoDevelop 0.14 (stable version available for Gutsy)
What’s new in MonoDevelop 0.15 (stable version but not available for Gutsy, need to compile from sources)
What’s new in MonoDevelop 1.0 Beta 1 (0.16) (unstable version, need to compile from sources)
What’s new in Mono 2.1.4 (stable version available for Gutsy)
What’s new in Mono 2.1.5 (stable version but not available for Gutsy, need to compile from sources)

Keep track of Mono development(RSS)


If you want to receive future posts by email, enter your email address here:

Related Posts:

October 30, 2007

Finally Got 3D Desktop Effects in My Ubuntu Gutsy (ATI Hardware)

Filed under: GNU/Linux, Ubuntu — tabrez @ 7:16 pm

Yesterday’s sad revelation : VMWare Guest Tools don’t work with Ubuntu Gutsy Gibbon. And I was thinking earlier that it might be one of the quirks of the RC version of Gutsy and was hoping that it will all work well when the final version gets released but no such luck.

So I decided to install it on the real hardware. To get something more out of my efforts, I decided to also try out Gutsy’s support for the Compiz desktop effects. The installation itself went smoothly in typical Ubuntu installation method.

As soon as Ubuntu gutsy was installed, it prompted me if I want the restricted drivers to be installed. I graciously accepted the offer but received an error in response saying “xorg-driver-glrx is not enabled.”

xorg-driver-glrx error when installing restricted drivers in ubuntu gutsy gibbon

When I had installed Ubuntu Gutsy RC1, it had automatically prompted me to enable certain repositories, took me to “Software Sources” dialog box, and after I had enabled the repositories(and refreshed the package list), it had continued installing the restricted drivers. It was a seamless process - everything was handled automatically and I only had to just keep clicking the “OK” buttons.

I don’t know what has changed between RC1 and the final release but I had to dismiss the above mentioned error window, manually go to Administration -> Software Sources and enable the repositories listed there.

Enabling All Ubuntu Gutsy Gibbon Repositories/Software Sources

It failed to refresh the packages and I realised that Internet is actually not working on the Gutsy yet. So I looked around a bit, changed Password Type in Network Settings from “WEP Text” to “WEP Personal” and felt relieved to finally be able to load the Google in the web browser. After successfully refreshing the package contents this time, the restricted drivers got installed without giving me any more errors.

ATI X300 graphic card restricted driver installed by Ubuntu Gutsy Gibbon

The desktop effects were still absent though. I checked System -> Preferences -> Appearance -> Visual Effects and tried to select something like “Normal” or “Extra” effects there, but got the error “The composite extension is not available” on both the occasions. I then checked the output of ‘compiz ––replace’ which indicated to me that I probably need to install the xserver-xgl drivers, so went ahead and installed it from the command line:

sh# sudo aptitude install xserver-xgl

And while I was at it, installed the compiz configuration tools too:

sh# sudo aptitude install compizconfig-settings-manager

In summary, the following command now informs me that everything is already there and nothing needs to be installed:

sh# sudo aptitude -y update && sudo aptitude dist-upgrade && sudo aptitude install xserver-xgl && sudo aptitude install compiz compiz-core compiz-fusion-plugins-extra compiz-fusion-plugins-main compiz-gnome compiz-plugins

No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

As you can see, everything is already installed. Now I went to System -> Preferences -> Appearance and selected the “Normal” radio button. Success! So I went ahead and selected “Custom” radio button this time and started playing with different settings by going to System -> Preferences -> Advanced Desktop Effects Settings.

Where to go from here? If you get lucky like me with your ATI hardware(my graphics card is ATI Mobility Radeon X300), you can learn more about Compiz by going to Desktop Effects with Compiz

If you are unable to get the 3D effects enabled even after installing the xserver-sgl driver, first try this ATI thread on Ubuntu forums, and in case you don’t find any success there, you can search the web for your ATI card or try asking for help on Launchpad Answers, Ubuntu Forums or Ubuntu IRC channel(#ubuntu at irc.freenode.net). I recommend you keep the output of the following commands handy with you when asking for help:

lspci | grep VGA
compiz ––replace
glxinfo | grep direct
cat /etc/X11/xorg.conf | grep Composite

Update: Here is a nice how-to by Ubuntu Forums member michael37 on how to get 3D Desktop effects for ATI cards for fresh Gutsy installation or an upgrade from Feisty to Gutsy.

Another ATI success story I came across: Compiz for ATI X1950XT


If you want to receive future posts by email, enter your email address here:

Related Posts:

July 19, 2006

Installing Ruby on GNU/Linux(Gentoo, (K)Ubuntu, Fedora, SUSE) And MS Windows

Filed under: GNU/Linux, Gentoo, Ruby/Rails, Ubuntu — tabrez @ 12:05 pm

Installing Ruby on Gentoo:

To install Ruby on Gentoo, run the following command(as root) in a shell:

sh# emerge ruby ruby-mode

You can add a few ‘USE’ keywords if you want to install additional Ruby support(like database integration, CGI support etc). Add the following line to the /etc/portage/package.use file(keywords that are already present in ‘USE’ flag of /etc/make.conf file need not be added):

dev-lang/ruby docs examples fastcgi mysql

‘ruby-mode’ adds the ruby mode to the Emacs editor while editing .rb files. Use ‘ruby-modes’ to add similar support to XEmacs. You need to add some text to .emacs file from your home directory; see this to know how to do it.

Installing Ruby on (K)Ubuntu:

Preparation:

A little note before you start installing Ruby on (K)Ubuntu:
There are two versions of Ruby available in the Ubuntu repositories:

Ruby 1.8.4 Ruby 1.9.0

1.8.4 version can be installed by appending 1.8(Eg. ruby1.8, irb1.8 etc) to the respective package names. Similarly, 1.9 version can be installed by appending 1.9(Eg. ruby1.9, irb1.9 etc) to the respective package names. If nothing is appended(Eg. ruby, irb etc), what debian considers as default version of ruby(currently 1.8.4) will be installed.

Once Ruby is installed, the command to invoke the Ruby interpreter would depend on which version of it is installed. Like, if ruby1.8 is installed, ruby can be invoked using ‘ruby’ or ‘ruby1.8′ commands(‘ruby’ will be a symbolic link to ‘ruby1.8′):

sh# ruby1.8 first.rb
sh# ruby first.rb
sh# ls -l `which ruby`
lrwxrwxrwx 1 root root 7 2006-07-18 18:47 /usr/bin/ruby -> ruby1.8

(the quotes in the third command are inverted quotes and not single quotes)

Use ‘ruby1.9′ if 1.9 version is installed.

If all this sounds confusing, just follow my recommended way of installing Ruby and skip the ‘Optional’ part.

My recommended way of installing Ruby on (K)Ubuntu:

To install Ruby on Ubuntu family of operating systems, type the following command in a shell:

sh# sudo apt-get install ruby ruby1.8 libruby1.8 irb irb1.8 rdoc rdoc1.8 ri ri1.8 ruby1.8-examples ruby1.8-elisp ruby-manual rubybook

(Or search and install these packages using Synaptic(on Ubuntu) or Adept(on Kubuntu) Package Manager.)

Running commands like ‘ruby’, ‘irb’ etc will invoke the latest stable versions:

sh# ruby -v
ruby 1.8.4 (2005-12-24) [i486-linux]
Optional

To install the 1.9 version(which is not stable as of now), use the following command:

sh# sudo apt-get install ruby ruby1.9 libruby1.9 irb irb1.9 rdoc rdoc1.9 ri ri1.9 ruby1.9-examples ruby1.8-elisp ruby-manual rubybook
sh# ruby -v
ruby 1.9.0 (2006-04-21) [i486-linux]

Of course you can also have both 1.8.4 and 1.9 versions installed on the system at the same time. Run the following command to do so:

sh# sudo apt-get install ruby ruby1.8 ruby1.9 libruby1.8 libruby1.9 irb irb1.8 irb1.9 rdoc rdoc1.8 rdoc1.9 ri ri1.8 ri1.9 ruby1.8-examples ruby1.9-examples ruby1.8-elisp ruby-manual rubybook

In this case, use ‘ruby’ to execute the 1.8.4 version of the interpreter and use ‘ruby1.9′ to run the 1.9 version.

sh# ruby -v
ruby 1.8.4 (2005-12-24) [i486-linux]
sh# ruby1.9 -v
ruby 1.9.0 (2006-04-21) [i486-linux]
What about ruby-gems?

I don’t recommend installing additional Ruby packages using the ‘rubygems’ utility if you use a distribution specific package manager(apt, emerge etc) to manage the software on your system. Debain community strongly discourages its use to install the ruby packages(rightly so), as it doesn’t follow the package management conventions of Debian’s package manager(and hence can mess up with it and stop it from working properly). Same goes for Gentoo OS too. Go here to read more information on this. But if Ruby is (one of) the most important software for you, then ‘rubygems’ can make it very easy to install the latest versions of Ruby related software, long before they are added to the Debian or Gentoo repositories. In that case, follow the documentation on how to install ‘rubygems’ and how to install Ruby packages using it from this page.

In Gentoo, you can do this:

sh# emerge rubygems

Installing Ruby on Fedora/SUSE/Mandriva etc:

Use RPMs! Hunt them down using google.com or rpmfind.net and then install them one by one in the order.
Or use the package manager of each distribution(‘yum’, ‘yast’ and ‘urpmi’ respectively) and hope for the best. I have tested with yum and yast and at least they did not create too many issues for me:

Ruby on Fedora using yum:

If the yum configuration files(fedora.repo etc) are properly setup, you can install Ruby using the following command:

sh# yum install ruby.i386 ri.i386 ruby-mode.i386
sh# ruby -v
ruby 1.8.4 (2005-12-24) [i386-linux]

Above command will install ruby, irb, ri, rdoc commands and Ruby mode for Emacs. You need to add the following line to ‘.emacs’ file present in your home directory(create it otherwise) to enable Ruby mode in Emacs editor:

(require ‘ruby-mode)

On SUSE, use YaST to install ‘ruby’, ‘ruby-doc-ri’ and ‘rubygems’ packages by searching for them from the YaST interface(YaST->Software Management->Search).

sh# ruby -v
ruby 1.8.2 (2004-12-25) [i586-linux]

‘ruby’ and ‘rubygems’ are available on the SUSE 10.1 DVD itself; you can add repositories from the Internet to install the other Ruby packages(ruby-docs-ri etc), or use ‘rubygems’ to install them.
Add the following in the YaST configuration (YaST->Installation Source) if you want to install ‘ruby-docs-ri’ from the Internet:

Protocol: FTP
Server Name: ftp.mirrorservice.org
Directory on Server: /distribution/SL-10.0-OSS/inst-source/
Authentication: Anonymous

Another way would be to simply download all the needed RPM files by manually searching for them on the web and installing them directly without bothering with yast. Same can be done for Mandriva and other RPM based distributions.

Installing Ruby on Microsoft Windows:

Download the Ruby Windows installer file from the following url: Ruby 1.8.4
(blog entries become outdated very soon; this is version 1.8.4, currently the latest stable version. Always Google for the latest stable version to check if this url still useful to compensate my laziness in updating the above link once a new version is released. 40+ words waster for the lack of Package Manager in Microsoft Windows.)

Click on the installer file and follow the wizard. Once finished, you have three ways to run your Ruby programs(assuming its Windows XP):

All the menu items are available at: Start->All Programs->Ruby-184-19, so first go there.
Menu for Ruby Programs
Then,

Select fxri-Interactive Ruby Help & Console menu item to load the interactive Ruby interpreter. Run your Ruby programs at the ‘irb’ prompt.

Interactive Ruby Shell(irb) And Help

Select FreeRIDE menu item, which will open a minimal IDE to write, debug and run Ruby programs.

FreeRIDE IDE For Ruby

(Recommended)Use SciTE editor.
Select SciTE menu item. This will open the excellent editor called SciTE that supports many programming languages other than Ruby, and is also available for many other operating systems(including GNU/Linux). Its one of the best programming editors available today.

Programmable Editor SciTE for Ruby

After finishing editing and saving the program with SciTE, go to the command prompt(Start->All Programs->Accessories->Command Prompt), change to the directory where you have saved the program and run it using the ‘ruby’ command.

C:\myprogs>ruby first.rb

End Note:

This article describes the installation of basic Ruby software. There are many related packages that can be installed to get additional functionality, like database bindings for popular database software(mysql, postgre), email support, gui programming(gtk, qt), rails, soap etc. Hopefully, I will cover installation of these packages in a future article(also planning to post an article on using various popular IDEs(Eclipse, Komodo) to create Ruby programs in Windows and GNU/Linux OS), so check back if you are interested.


If you want to receive future posts by email, enter your email address here:

Related Posts:

Next Page »

Copyright (c) 2006, 2007 Tabrez Iqbal.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


Powered by WordPress
This website is hosted by Dreamhost


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser
Mobilytics