I have been working on various technologies from the past 2 years. Just a couple of months ago , my friend Paul has suggested me to pick up my speed on ruby and ruby on rails as he’s got a few projects coming and likes me to work on them.
This is probably the third time i have installed linux ubuntu on my computer as i kept fiddling with Virtual machine and actual installation. First two of my installation experiences were as bad as it was this time. could never get anything working on the first try which im trying to install ruby. Various situations where things got messed up.
So i decided to write a few guidelines to all those who started learning ruby and ROR(ruby on rails).
if you are at the learning phase, i’d suggest you to install using the source with the latest source which you can find at http://rubyinstaller.org/downloads/ Ruby Installer Page . This way you dont have to worry about RVM and installing packages and gems depending on RVM.
Download the source file and extract it in a location. Make sure GCC is already installed. you can install it by typing this on the console
apt-get install gcc
then go to the location of the ruby install files.
sudo make install
I would suggest you to use sudo because there are a few files which requires permissions during the installation.
After ruby installation is complete , check if ruby commands are working on the console. to do this type
This returns the details of the ruby version install on your computer
Then go to ruby gems http://rubygems.org/pages/download website and install rubygems through console by typing .
sudo ruby setup.rb
To check if gems have been installed successfully type
this is return a few functions available to perform using gems.
If these steps are done, let proceed further and install the latest ruby on rails gem
type the command
gem install rails
If it has been installed successfully then all the required libraries have already been installed. But with me this dint happen. I got this error
ERROR: Loading command: update (LoadError)
no such file to load — zlib
ERROR: While executing gem … (NameError)
uninitialized constant Gem::Commands::UpdateCommand
I spend more than 2 hours looking for the solution and finally got the solution in a forum.
Why did it return this error ?
Ruby and Ruby gems depend upon a compression library called zlib which manages the compression and decompression of most of the files.
Normally ruby installs this library during the installation but sometimes it skips it - i am expecting it to be a mess up in the control flow.
What to do now ?
Lets make sure we have this library first .
sudo apt-get install zlib1g-dev
Once it has been installed lets tell our ruby that it has been installed now so she can use it for its operations. to do that go to the ruby installation files . In my case i am using ruby-1.9.3-p0 and it is at
navigate to the folder /ext/zlib . to do that type
now lets re install this module.
sudo ruby extconf.rb
A make file will be generated for this module separately . So lefts finish the installation.
sudo make install
Voila ! ! Its finally done. we wont be having the issues related to zlib anymore.
to check it , lets try to install rails gem again with the command mentioned above
In case you have anymore issue with the gem installation because of ssl like
no such file to load — openssl
Follow the same procedure we used for zlib. navigate to /ext/openssl in my case it is
then install this module separately by
sudo ruby extconf.rbsudo makesudo make install
Now we’re finally done with installing zlib and openssl. these 2 libraries have caused most of the issues i faced during my installation.
Hope it helped you as well