Windows command console is quite primitive, it is good to have the power of Unix console on your Windows. If you are like me, you could have installed Cygwin and you probably have installed Ruby using One-Click Ruby Installer, but encountered some problems running ruby, rails and other ruby-related commands on Cygwin.

Well, same here, and I think it is easier to install a seperate copy of Ruby under Cygwin. Fixing the path differences between Windows and Cygwin consoles can be messy, here are some tips to install RoR on Cygwin:

  1. Install a seperate copy of Ruby using Cygwin setup wizard. Expand All > Devel and select ruby and proceed with the setup.

  2. After you have installed Ruby, download Ruby Gems, extract the setup files to a temporary directory, and when you try to run the setup, you probably will encounter an error.

    ruby setup.rb
    ruby: No such file to load -- ubygems (LoadError)

    Tips:

    When you install Ruby using One-Click installer, it will set an environment variable RUBYOPT=rubygems. It tells ruby to load rubygems library when running a ruby file. You have not installed Rugy Gems, thus the setup.rb execution failed.

    Just unset RUBYOPT variable and re-run the Ruby Gems setup:

    unset RUBYOPT
    ruby setup.rb

  3. Then you can install Rails using Ruby Gems by running:

    gem install rails --include-dependencies

  4. You have irb configuration file (.irbrc file) under your windows home directory, and you still want to use it in Cygwin, create a symbolic link to the file in Cygwin home directory

    cd $HOME
    ln -s [/path/to/windows-user/homepath/].irbrc .irbrc

31 Comments . Comments Feed . Trackback URI
Mon, 1 May 06 05:51 am . Adolfo R. Brandes wrote:

Thanks a lot for this tip, saved me a whole lot of time.

Tue, 25 Jul 06 01:27 am . Herryanto Siatono wrote:

Np. Adolfo, great to be able to help.

Wed, 16 Aug 06 11:57 pm . David T wrote:

Thanks for that. Just one point, it’s worth uninstalling Ruby from windows first and making sure you have the cygwin version. You get some strange errors if the windows version is still installed.

After I uninstalled, your instructions worked great, thanks.

Tue, 10 Oct 06 08:43 am . kodecharlie wrote:

Worked like a charm. Thanks for the RoR/cygwin configuration tips.

Thu, 16 Nov 06 10:49 am . Aubrey wrote:

That was a huge help. Thanks!

Wed, 7 Feb 07 11:30 pm . Mark Yoshikawa wrote:

Thanks Herryanto!
I ran across a couple of installations where running “gem install rails –include-dependencies” gave me the following error:

ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find rails (> 0) in any repository

I believe it was because I needed rake and did not have it so possibly doing: “gem install rake –include-dependecies” before that line worked out for me…

Wed, 7 Feb 07 11:26 pm . Herryanto Siatono wrote:

That’s a weird error message, you may want to check out this link. Seems to be related to a corrupted source_cache folder.

Tue, 13 Mar 07 09:40 am . Dylan Hunter wrote:

@Mark, thanks much for the rake install thing. Was having the same error under Cygwin, and that fixed me right up - thanks! :)

Tue, 13 Mar 07 06:09 pm . codeRat wrote:

I have the same problem as Mark. But solved it with
“gem update –system”

Thanks for the tip about installing RoR on cygwin :D

Sat, 17 Mar 07 04:20 am . Charles Roper wrote:

One question: now that I’ve got gems installed under cygwin, should I install the native “mswin32″ versions of things such as mongrel and hpricot, or should I stick to the ruby versions?

Also, if I run “gem update –system” I get a stream of errors like this one:

14372248 [main] ruby 4208 C:\cygwin\bin\ruby.exe: *** fatal error - unable to remap C:\cygwin\bin\cygssl-0.9.8.dll to
same address as parent(0×340000) != 0×4730000
14378828 [main] ruby 1752 fork: child 4208 - died waiting for dll loading, errno 11

Is there any way to fix this?

Sat, 17 Mar 07 11:47 am . Herryanto Siatono wrote:

@charles I”ve never encountered such issue, but found this discussion, have u checked it out?
http://www.mail-archive.com/cygwin@cygwin.com/msg77668.html

@codeRat You are most welcome.

Sat, 17 Mar 07 09:15 pm . Charles Roper wrote:

Thanks very much for the link - that lead to the solution. I should have thought to check there myself. :)

Here’s exactly what I did to solve the problem:

1. Run Cygwin’s setup.exe and install the rebase package.
2. At the Windows cmd line, run \cygwin\bin\ash
3. At the ash prompt, run /bin/rebaseall

Problem solved.

I suspect there may be a surge in popularity for Cygwin if E-TextEditor (essentially TextMate for Windows) takes off as it makes heavy use of Cygwin and Ruby. So you instructions may come in very handy for those of us switching to e.

Sat, 17 Mar 07 11:23 pm . Herryanto Siatono wrote:

Np Charles, great to be able to help. Thanks for the summary, would be helpful for the others.

Tue, 8 May 07 05:39 am . Minh wrote:

Merci de la france !! :)

Sat, 9 Jun 07 02:40 pm . Dave wrote:

What mail program could you use for ActiveMailer with this type of setup? How would it be configured in the environment.rb file?

Sun, 10 Jun 07 11:58 pm . Herryanto Siatono wrote:

I think for this environment the easiest will be SMTP mail.

For the configuration, please refer here.

http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer

Fri, 10 Aug 07 11:52 pm . Max wrote:

Someone is successful to make to work the sortcuts from keyboard for Rails in e?

Thu, 6 Sep 07 06:57 am . GSIY … Ruby-Rails Portal wrote:

[…] The answer to the Ruby/Cygwin problem is here. […]

Fri, 21 Sep 07 10:27 pm . Chris Bloom wrote:

@Charles Roper, Herryanto Siatono, Mark Yoshikawa

Thanks to all of your suggestions I know have Ruby and Rails installed in parallel on Windows and Cygwin :) The trick was first to use rebase, then install the rake gem, then install the rails gem.

Thanks!

Tue, 27 Nov 07 09:48 am . Sunil Karkera wrote:

Thank you very much! unset rubyopt saved me a bunch of time!

Tue, 25 Dec 07 12:59 pm . Dat Chu wrote:

Thanks for this easy to follow instructions. Saved me a bunch of hours :)

Fri, 4 Jan 08 04:35 pm . Liany Lim wrote:

Thanks for the tips, Herryanto. It’s really helpful.
@Mark, thanks for your tips too. :)

Wed, 9 Jan 08 08:22 am . Pasquale wrote:

This is brilliant. Thanks :D

Sun, 2 Mar 08 05:39 am . Floyd wrote:

Thanks for posting this very helpful information (and for the directness and concision of the post). I owe you an hour or three.

Sun, 2 Mar 08 08:54 am . Floyd wrote:

I encountered the RoR/Cygwin issue (/dev/urandom not found) mentioned here, and the solution seemed to work: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/0a371707459f2b8e/5af934967f3449ec?#5af934967f3449ec

Tue, 8 Apr 08 10:24 pm . ndgiang84 wrote:

thanks Herryanto Siatono for the detailed instructions and others for those informative comments

greatly help.

Wed, 16 Jul 08 01:56 am . Seth wrote:

THANK YOU! Oh my word, it’s been frustrating not knowing how to work with these errors in E - texteditor. Please know you have saved me many brain cells. The need for the ash command outlined by Charles Roper was essential.

Thu, 16 Oct 08 10:24 am . Terence wrote:

This has enabled to get developing on my windows laptop instead of using an old borrowed g4 mac. Thanks.

Wed, 17 Dec 08 03:38 pm . 在Cygwin中使用Ruby « Think Louder wrote:

[…] 如果在Cygwin中安装rubygems之前装过One-Click Ruby Installer,可能会遇到环境变量的问题。请看Pluit的解决方案。 […]

Thu, 18 Dec 08 11:14 am . Ruby, Rails and Cygwin | A Stata Mind wrote:

[…] Rails is another matter. I installed it with help from here and look, it worked: $ rails . exists create app/controllers create app/helpers create app/models [snip] Why Rails? Because according to its inventor, Rails is so great that it’s probably easier to learn Ruby in order to use it, than it would be to learn another framework in some language you already know. The full citation is here. Well, I hope it’s true. I’ll keep a running progress report here. […]

Tue, 2 Jun 09 05:00 pm . Eliot Sykes wrote:

If anyone gets a problem like “No such file or directory - /tmp/mysql.sock” try changing your host in database.yml to 127.0.0.1 (from localhost).

Using an IP address forces TCP/IP to be used to connect with mysql instead of a unix socket file connection.

Add Your Comment



(optional)