Help with Ruby under cygwin

In order to use git on my laptop (MS XPproSP3) I ended up installing the
cygwin environment. I tried MSysGit but it failed to run and the
maintainer was, shall we say, less than enthusiastic with my bug report.

Now, everything works from the standard windows dos box. However, when
I try and run a ruby utility such as gem, rake or rails from within the
cygwin bash shell window then each gives the same style of error:

$ which rails
/cygdrive/c/usr/lib/ruby/bin/rails
$ rails
c:\usr\lib\ruby\bin\ruby.exe: No such file or directory –
/cygdrive/c/usr/lib/r
uby/bin/rails (LoadError)
$
$ which gem
/cygdrive/c/usr/lib/ruby/bin/gem
$ gem list
c:\usr\lib\ruby\bin\ruby.exe: No such file or directory –
/cygdrive/c/usr/lib/r
uby/bin/gem (LoadError)
$
$ which rake
/cygdrive/c/usr/lib/ruby/bin/rake
$ rake
c:\usr\lib\ruby\bin\ruby.exe: No such file or directory –
/cygdrive/c/usr/lib/r
uby/bin/rake (LoadError)

I am not having this problem with anything else and so I am first asking
for help here since I expect the cygwin people will turn me to this
forum in the end in any case.

Any insight anyone can provide me as to what is going on here would be
most appreciated.

2008/6/12 James B. [email protected]:

$ rails
$
$ which rake
/cygdrive/c/usr/lib/ruby/bin/rake
$ rake
c:\usr\lib\ruby\bin\ruby.exe: No such file or directory –
/cygdrive/c/usr/lib/r
uby/bin/rake (LoadError)

I am not having this problem with anything else and so I am first asking
for help here since I expect the cygwin people will turn me to this
forum in the end in any case.

Hm, the path to your ruby.exe looks suspicious. What’s the output of
“type -a” at a bash prompt? For me it’s this:

16:55:17 ~$ type -a ruby
ruby is /usr/bin/ruby
ruby is /bin/ruby
ruby is /usr/bin/ruby

Also, what does echo “$PATH” output? Maybe you are pulling the wrong
Ruby.

Did you use the Ruby package that comes with cygwin or did you install
from sources?

Kind regards

robert

James B. wrote:

$ rails
$

Any insight anyone can provide me as to what is going on here would be
most appreciated.

I’m not on my Cygwin system at the moment; I can check it later today
and give you a definitive answer. But it looks like your paths aren’t
right. The Ruby executable itself in a Cygwin prompt should show up as
/usr/bin/ruby. If you type ‘which ruby’ from the prompt that’s what you
should see. And the libraries should be in /usr/lib/ruby/… .

What I would recommend is uninstalling everything and reinstalling
rubygems from source. Then reinstall rails and its dependencies with
“gem install”.

Thanks.

Yes, I have a previous windows only install of ruby and gem. I will
remove that and use the cygwin version and see how things shake out
after that.

In order to use git on my laptop (MS XPproSP3) I ended up installing the
cygwin environment. I tried MSysGit but it failed to run and the
maintainer was, shall we say, less than enthusiastic with my bug report.

I’m not sure if I understand. MSysGIT sounds like it would be
something from msys (ie. mingw). Why would you want to run a mingw git
from cygwin that has its own git?

cygwin has different path conventions that mingw or win32. I’d suggest
to run rxvt & bash.

It also seems slightly less than 100% optimal that you installed the
cygwin stuff to c:. IIRC the installer suggests c:\cygwin.

I removed the windows install of ruby and all the gems. I then
installed ruby from cygwin. I then downloaded rubygems-1.1.1.tgz from
rubyforge. I checked that the the path variables were correctly set and
that the same ruby executable was accessed from both the native cmd
window and the cygwin shell.

$ which ruby
/usr/bin/ruby

and

C:\DATA\DOWNLOAD\SOFTWARE>which ruby
/usr/bin/ruby

I then expanded the tarball and made that directory the pwd. When I run
ruby setup.rb, in either the cmd window or the cygwin bash shell I see
this error:

BASH SHELL
byrnejb@HAL-M13
/cygdrive/c/DATA/DOWNLOAD/SOFTWARE/org.rubyforge/rubygems/rubyge
ms-1.1.1
$ ruby setup.rb
ruby: no such file to load – ubygems (LoadError)

CMD WINDOWS SHELL
C:\DATA\DOWNLOAD\SOFTWARE\org.rubyforge\rubygems\rubygems-1.1.1>ruby
setup.rb
ruby: no such file to load – ubygems (LoadError)

Any ideas as to what is going on?

Under a cygwin term, I had to 1st set:

RUBYOPT=;export RUBYOPT

before installing rubygems with

$ ruby setup.rb

[Some installation output:

ruby setup.rb
install -c -m 0644 rbconfig/datadir.rb
/usr/local/lib/ruby/site_ruby/1.8/rbconfi
g/datadir.rb
mkdir -p /usr/local/lib/ruby/site_ruby/1.8/rubygems
install -c -m 0644 rubygems/builder.rb
/usr/local/lib/ruby/site_ruby/1.8/rubygem
s/builder.rb
install -c -m 0644 rubygems/command.rb
/usr/local/lib/ruby/site_ruby/1.8/rubygem
s/command.rb
… (MANY MORE LINES)

]

Best to you,
Bob

Ehrick, Robert O wrote:

Under a cygwin term, I had to 1st set:

RUBYOPT=;export RUBYOPT

before installing rubygems with

$ ruby setup.rb

Best to you,
Bob

Those were the magic words. Many thanks.

ThoML wrote:

In order to use git on my laptop (MS XPproSP3) I ended up installing the
cygwin environment. I tried MSysGit but it failed to run and the
maintainer was, shall we say, less than enthusiastic with my bug report.

I’m not sure if I understand. MSysGIT sounds like it would be
something from msys (ie. mingw). Why would you want to run a mingw git
from cygwin that has its own git?

I only installed the cygwin environment when it became obvious that the
MsysGiT maintainers were not interested in looking at my problem in the
near term, if ever. So the order of events was:

Ruby on Windows => OK,
Gem on Windows => OK,
MSysGiT on Windows => FAIL,
cygwin with GiT => OK,
Gem on Windows => FAIL

It also seems slightly less than 100% optimal that you installed the
cygwin stuff to c:. IIRC the installer suggests c:\cygwin.

cygwin is installed in C:\cygwin

Robert K. wrote:

I am not having this problem with anything else and so I am first asking
for help here since I expect the cygwin people will turn me to this
forum in the end in any case.

I guess I will ask myself - this is long but complete :slight_smile:

If this is the wrong place to post this let me know.
I have looked about fairly extensively for some form of coherant and
coplete doc or howto but they are all vague and I have seen numerous
postings that others have problems. If I get it figured out I will post
my explicit cleaned up instructions somewhere so others with no ruby
experience whatsoever can repeat the process easily.

GOAL I want to get ruby and Rake up on cygwin. windows XP pro sp2 so I
can evaluate rake as the “make and ant” killer and maybe use it as our
primary cross platform build system. AND also to create an explicit set
of non-vague repeatable sitructions for others to do so.

I am following the “pickaxe book” bit on getting started.

**** So far

I downloaded and installed cygwin “fresh” as an administrator and
included the ruby package “1.8.7-p72-1”. (latest)
the command ruby is found from the bash shell after installation.

~$ which ruby
/usr/bin/ruby

There is no RUBYOPT in my environment variables.

~$ echo X $RUBYOPT X
X X

from a cygwin bash shell.

~$ ruby
(now in ruby shell)
puts “xxx”
(control D)
xxx
~$

The interpreter seems to work.

I downloaded a copy of "OneClickInstall to get that version as a
reference and unpacked it so I could get the “samples”, I did not run
it’s ruby and removed it from the path it installed so as not to
conflict with cygwin. I also removed the RUBYOPT environment variable
it installed, closed and re-opened the bash shell to purge it’s cache,
then:

~$ echo X $RUBYOPT X
X X

I found the “samples” directory from the one click install and found
eval.rb.

~$ cd /cygdrive/c/ruby/samples/RubySrc-1.8.6-p111/sample$ ls eval.*
/cygdrive/c/ruby/samples/RubySrc-1.8.6-p111/sample$ ls eval.*
eval.rb

from bash:

/cygdrive/c/ruby/samples/RubySrc-1.8.6-p111/sample$ ruby ./eval.rb
ruby: no such file to load – ubygems (LoadError)

Ok I saw several places one had to install “rubygems” in “ths customary
way” ok so I guessed what the “customary way” is,
I downloaded. rubygems-0.8.11.zip
It unpacks to a directory ./rubygems-0.8.11/*

Ok where do I put it? in /usr/lib/rubygems-0.8.11 ??
I tried this
(this did not get rid of the load error)
I renamed to to /usr/lib/ruby
(this did not get rid of the load error)

where do I go from here:

(the objective here is to expand this into an explicit step by step set
of instructions for getting ruby and rake set up under cygwin-XP

a - so I can do it to evaluate rake as a “make and ant killer”
b - so others can repeat this process without needing to ask questions
to set up their machines :slight_smile:

Peter K.

Replying with my own message.
OK - It seems (guesswork here) that one must unpack the runygems zip
file “anywhere” and then CD to it’s root and do:

$ ruby ./setup.rb
And it executes a setup program, this succeeds.

Setup.rb however creates a directory called /usr/bin/ruby
so now in cygwin if I get:

$ ruby
bash: /usr/bin/ruby: is a directory

since /usr/bin is in the path.

How does one get around this?
Take /usr/bin out of the path?
always use “ruby.exe” explicitly?
Configure ruby to put its stuff somewhere else?

???

Peter Pk wrote:

Robert K. wrote:

I am not having this problem with anything else and so I am first asking
for help here since I expect the cygwin people will turn me to this
forum in the end in any case.

I guess I will ask myself - this is long but complete :slight_smile:

If this is the wrong place to post this let me know.
I have looked about fairly extensively for some form of coherant and
coplete doc or howto but they are all vague and I have seen numerous
postings that others have problems. If I get it figured out I will post
my explicit cleaned up instructions somewhere so others with no ruby
experience whatsoever can repeat the process easily.

GOAL I want to get ruby and Rake up on cygwin. windows XP pro sp2 so I
can evaluate rake as the “make and ant” killer and maybe use it as our
primary cross platform build system. AND also to create an explicit set
of non-vague repeatable sitructions for others to do so.

I am following the “pickaxe book” bit on getting started.

**** So far

I downloaded and installed cygwin “fresh” as an administrator and
included the ruby package “1.8.7-p72-1”. (latest)
the command ruby is found from the bash shell after installation.

~$ which ruby
/usr/bin/ruby

There is no RUBYOPT in my environment variables.

~$ echo X $RUBYOPT X
X X

from a cygwin bash shell.

~$ ruby
(now in ruby shell)
puts “xxx”
(control D)
xxx
~$

The interpreter seems to work.

I downloaded a copy of "OneClickInstall to get that version as a
reference and unpacked it so I could get the “samples”, I did not run
it’s ruby and removed it from the path it installed so as not to
conflict with cygwin. I also removed the RUBYOPT environment variable
it installed, closed and re-opened the bash shell to purge it’s cache,
then:

~$ echo X $RUBYOPT X
X X

I found the “samples” directory from the one click install and found
eval.rb.

~$ cd /cygdrive/c/ruby/samples/RubySrc-1.8.6-p111/sample$ ls eval.*
/cygdrive/c/ruby/samples/RubySrc-1.8.6-p111/sample$ ls eval.*
eval.rb

from bash:

/cygdrive/c/ruby/samples/RubySrc-1.8.6-p111/sample$ ruby ./eval.rb
ruby: no such file to load – ubygems (LoadError)

Ok I saw several places one had to install “rubygems” in “ths customary
way” ok so I guessed what the “customary way” is,
I downloaded. rubygems-0.8.11.zip
It unpacks to a directory ./rubygems-0.8.11/*

Ok where do I put it? in /usr/lib/rubygems-0.8.11 ??
I tried this
(this did not get rid of the load error)
I renamed to to /usr/lib/ruby
(this did not get rid of the load error)

where do I go from here:

(the objective here is to expand this into an explicit step by step set
of instructions for getting ruby and rake set up under cygwin-XP

a - so I can do it to evaluate rake as a “make and ant killer”
b - so others can repeat this process without needing to ask questions
to set up their machines :slight_smile:

Peter K.

more:

so a default install of cygwin produces mount locations as follows.

$ mount -m
mount -f -s -b “C:/cygwin/bin” “/usr/bin”
mount -f -s -b “C:/cygwin/lib” “/usr/lib”
mount -f -s -b “C:/cygwin” “/”
mount -f -s -b “C:/cygwin/home” “/home”
mount -s -b --change-cygdrive-prefix “/cygdrive”

Note /bin and /usr/bin are the same.

So somethign must be configured differently for it to work.
Any ideas?

Peter Pk wrote:

Replying with my own message.
OK - It seems (guesswork here) that one must unpack the runygems zip
file “anywhere” and then CD to it’s root and do:

$ ruby ./setup.rb
And it executes a setup program, this succeeds.

Setup.rb however creates a directory called /usr/bin/ruby
so now in cygwin if I get:

$ ruby
bash: /usr/bin/ruby: is a directory

since /usr/bin is in the path.

How does one get around this?
Take /usr/bin out of the path?
always use “ruby.exe” explicitly?
Configure ruby to put its stuff somewhere else?

???

cygwin is installed in C:\cygwin

It didn’t show up in your output which is why I suspected that you
mixed cygwin and non-cygwin apps which can cause troubles.

More: so it seems you have to set GEM_HOME to something else than the
default for the setup program which appears to be/usr/bin.ruby.

ie:

$ export GEM_HOME=/usr/local/lib/ruby
$ ruby ./setup.rb setup

$ ruby ./setup.rb install

This seems to put it in the right place anyway so that it doesn’t
interfere with the /usr/bin/ruby.exe in the path. and creates
/usr/local/lib/ruby

I’m assuming after this you then need GEM_HOME to be set to run anything
with gems in it. ?

Peter Pk wrote:

more:

so a default install of cygwin produces mount locations as follows.

$ mount -m
mount -f -s -b “C:/cygwin/bin” “/usr/bin”
mount -f -s -b “C:/cygwin/lib” “/usr/lib”
mount -f -s -b “C:/cygwin” “/”
mount -f -s -b “C:/cygwin/home” “/home”
mount -s -b --change-cygdrive-prefix “/cygdrive”

Note /bin and /usr/bin are the same.

So somethign must be configured differently for it to work.
Any ideas?

synopsis which I wish I had found earlier :slight_smile:

HOWTO: install cygwin with ruby, rubygems, and rake on windows XP
how to install cygwin with ruby, rubygems, and rake on windows XP

Download and install cygwin and make sure the “ruby” package is
selected.

make sure the RUBYOPTS environment variable is empty or unset

Download and unpack the rubygems distribution zip or tar file into a
temporary area.

set GEM_HOME=/usr/local/lib/ruby in the system environment variables

In the cygwin bash shell cd to the root of what you unpacked.
execute these commands:

$ ruby ./setup.rb config
$ ruby ./setup.rb setup
$ ruby ./setup.rb install

set RUBYOPTS=rubyopts in system environment variables

Gems is now installed on cygwin ruby.
Now you can install rake

Download and unpack the rake distribution .zip or .tar file into a temp
area.
In the cygwin bash shell cd to the root of what you unpacked.
execute this command:

$ ruby ./setup.rb

Rake should now be installed.

PK

Chris L. wrote:

Is it not possible to do
gem install rake
now that you have rubygems installed ?

Chris

It is, but it doesn’t install the “rake” command to the /usr/bin area,
installing from the package distro using it’s supplied setup.rb does. I
of course, only found this out after trying both :slight_smile:

I want it under cygwin because some of our existing scripts etc are on
cygwin and run on both 'nix boxen and PCs.

BTW is there a WIKI for maintaining Ruby/Rake HOWTO docs?

I would have loved to find a succinct, complete, and accurate “HOWTO
install ruby with rake on windows cygwin”. I like many, when starting
out, start knowing absolutely nothing about ruby and rake, and the first
thing one does when starting anything is “install it”. So to promote
ruby/rake and prevent the “oh my god this is YO chaotic mess”
perception, the initial installation process has to be “reliable” or
“one-click” or in a single set of easy non-ambiguous instructions with
no “implicit” community or language specific knowledge assumed. It is
the gateway to perceiving an propagating system.

BTW - so far ruby/rake seems to be what I want a real interpreter
based “make” to do for creating build automation (and other things).
Now I have to convince management that it isn’t a chaotic hard to
maintain non-standard mess, and need to build a one-click installer to
put on our internal web site for the base system, and justify the
learning curve.

I want this to be a highly effective “ant poison” - I’m getting eaten
alive! :slight_smile:

gnu-make is now completely obsolete even though capable, cross platform
and “ubiquitous”. if for no other reason than it doesn’t handle paths
with spaces in them. But it also lacks programmability and modular
maintainability for large build systems.

PK

Gems is now installed on cygwin ruby.
Now you can install rake

Download and unpack the rake distribution .zip or .tar file into a temp
area.
In the cygwin bash shell cd to the root of what you unpacked.
execute this command:

Is it not possible to do
gem install rake

now that you have rubygems installed ?

Chris

It is, but it doesn’t install the “rake” command to the /usr/bin area,
installing from the package distro using it’s supplied setup.rb does. I
of course, only found this out after trying both :slight_smile:

That’s strange. I also use cygwin ruby. I have:

$ gem list | grep ‘rake’
rake (0.8.1)

installed through ruby gems, and “which rake” shows the rake
executable at /usr/bin/rake .

I also don’t recall having to set any environment variables to get
ruby to work. I have no $RUBYOPT set, for example. I downloaded
cygwin, and installed ruby using the cygwin package manager. Then I
downloaded rubygems 1.2.0, installed using setup.rb and everything
“just worked” after that. Perhaps this is why there is no detailed
HOWTO - the steps required in my case were quite minimal.

Apart from the occasional problem installing native binary based gems
I have found the ruby cygwin experience painless, and have never felt
the need to use the “one-click” installer. I can understand some
peoples aversion to cygwin though.

Is it possible that your system is using some non-standard defaults or
installation paths that are causing problems ? At some point perhaps I
can get a clean windows installation and try this again.

Chris

all I can do is report my experience.

If you wish to start with a virgin cygwin install, then write down
everything you did step by step, in detail, so I can repeat it here
exactly as you did it and test it, I can give you feedback.

I failed initially following the on-line instructions I found.
What I did:

I installed cygwin with with ruby with the latest version on c:\cygwin
I did do so after installing the ruby “OnClickInstall” and later
removing all the path and enviroment variables it created.

On cygwin I installed rubygems from rubygems-0.8.11.zip using the
./setup.rb
Then I first tried “gem remote --install rake” and didn’t get
the /usr/bin/rake command installed though it “succeeded” and updated
the contents of /usr/lib/ruby/1.8/rake.

now it is possible cygwin didn’t properly
update it’s “what’s in the path cache”

note: googling I see a more explicit gem command as
“gem install rake --source=http://gems.rubyforge.net”
I did not try that.

when I installed it from the package using ./setup.exe it apparently did
install the /usr/bin/rake, or in some way at that time cygwin now knew
where to find it.

I then tried to run the rake test suite, it barfed apparently needing
some “gem” libraries that are apparently not installed as part of the
rake initial setup on cygwin. and then I did:

$ gem install rcov (does this download or get out of the local cache?)
$ gem install flexmock (ditto)

assuming that might do the trick seeing that syntax elsewhere.

and then the rake test ran, though with some reported non-fatal errors.

(The I gave up on trying to make the test perfect, because it appeared
to be from some missing “session thing” which someone hinted was not
available on windows, and ordered the latest “pickaxe” book :slight_smile:

PK

Chris L. wrote:

It is, but it doesn’t install the “rake” command to the /usr/bin area,
installing from the package distro using it’s supplied setup.rb does. I
of course, only found this out after trying both :slight_smile:

That’s strange. I also use cygwin ruby. I have:

$ gem list | grep ‘rake’
rake (0.8.1)

installed through ruby gems, and “which rake” shows the rake
executable at /usr/bin/rake .

I also don’t recall having to set any environment variables to get
ruby to work. I have no $RUBYOPT set, for example. I downloaded
cygwin, and installed ruby using the cygwin package manager. Then I
downloaded rubygems 1.2.0, installed using setup.rb and everything
“just worked” after that. Perhaps this is why there is no detailed
HOWTO - the steps required in my case were quite minimal.

Apart from the occasional problem installing native binary based gems
I have found the ruby cygwin experience painless, and have never felt
the need to use the “one-click” installer. I can understand some
peoples aversion to cygwin though.

Is it possible that your system is using some non-standard defaults or
installation paths that are causing problems ? At some point perhaps I
can get a clean windows installation and try this again.

Chris

I deliberately removed GEM_HOME and tried it again and it still
installed in /usr/bin/ruby

When I explicitly set it to /usr/local/lib it went into the right place.
It is possible that the setup.rb cached the prior GEM_HOME when it did
it’s “configure” phase.

So it seems the only reliable way to make an explicit, accurate,
installation script is to explicity define GEM_HOME as part of the
procedure. Since “setup” isn’t explicitly asking for the items and/or
showing the current settings and asking “Y” or “N” to continue. ie: like
a debian install script.

toomln wrote:

Setup.rb however creates a directory called /usr/bin/ruby
so now in cygwin if I get:

�$ ruby
bash: /usr/bin/ruby: is a directory

I don’t know what you have done here but it seems to me that you made
a mistake around step #1.

If you have windows ruby installed too, make sure its directory isn’t
in your path before cygwin ruby and review any RUBY* environments
variables (unset RUBYOPT). Maybe also check $PATH so that no windows
commands with the same name as cygwin commands are used instead of
cygwin commands. Anything else should work smoothly.