Shared cygwin & command.com environments?

J

Jay Levitt

I've been using the Cygwin bash shell to do most of my command-line ruby
work, since it's a much nicer environment than command.com. However, since
my apps themselves are kicked off by Eclipse, using the standard
interpreter, I end up having to maintain two ruby builds, two sets of gems,
etc.

Worse, now that I upgraded to rake 0.7.1 with rails 1.1, it's somehow
looking in the wrong place for everything; in fact, bash seems totally
confused as to which ruby it's really running:

$ which ruby
c:\dev\ruby\bin\ruby.exe
[So it says I'm running the non-cygwin version]

$ ruby --version
ruby 1.8.4 (2005-12-24) [i386-cygwin]
[But actually seems to run the cygwin version!]

$ c:/dev/ruby/bin/ruby --version
ruby 1.8.2 (2004-12-25) [i386-mswin32]


$ /usr/local/bin/ruby --version
ruby 1.8.4 (2005-12-24) [i386-cygwin]

My $PATH puts /usr/local/bin first, and /cygdrive/c/dev/ruby/bin way down
near the bottom.

So... I'm thinking of blowing the whole mess away. Is there any way to get
cygwin bash to run the mswin ruby.exe successfully? Or at least get them
to share gem libraries? I remember that this used to crash.

And anyone have any idea why it's launching the right ruby when I type
"ruby", but giving the wrong one to "which" (and, I presume, launching rake
with the wrong one)?

Jay Levitt
 
R

Robert Klemme

Jay said:
I've been using the Cygwin bash shell to do most of my command-line ruby
work, since it's a much nicer environment than command.com. However, since
my apps themselves are kicked off by Eclipse, using the standard
interpreter, I end up having to maintain two ruby builds, two sets of gems,
etc.

Worse, now that I upgraded to rake 0.7.1 with rails 1.1, it's somehow
looking in the wrong place for everything; in fact, bash seems totally
confused as to which ruby it's really running:

$ which ruby
c:\dev\ruby\bin\ruby.exe
[So it says I'm running the non-cygwin version]

$ ruby --version
ruby 1.8.4 (2005-12-24) [i386-cygwin]
[But actually seems to run the cygwin version!]

$ c:/dev/ruby/bin/ruby --version
ruby 1.8.2 (2004-12-25) [i386-mswin32]


$ /usr/local/bin/ruby --version
ruby 1.8.4 (2005-12-24) [i386-cygwin]

My $PATH puts /usr/local/bin first, and /cygdrive/c/dev/ruby/bin way down
near the bottom.

So... I'm thinking of blowing the whole mess away. Is there any way to get
cygwin bash to run the mswin ruby.exe successfully? Or at least get them
to share gem libraries? I remember that this used to crash.

I'd rather do it the other way round: make cmd.exe call a batch script
that actually invokes bash and then cygwin's ruby. Feels more
comfortable to me.
And anyone have any idea why it's launching the right ruby when I type
"ruby", but giving the wrong one to "which" (and, I presume, launching rake
with the wrong one)?

Might have to do with the fact that "which" is not a shell builtin:
better use "type" for that on a bash:

09:23:11 [~]: type -a which
which is /usr/bin/which
which is /bin/which
09:23:11 [~]: type -a type
type is a shell builtin

Kind regards

robert
 
J

Jay Levitt

I'd rather do it the other way round: make cmd.exe call a batch script
that actually invokes bash and then cygwin's ruby. Feels more
comfortable to me.

Interesting.. any reason why? When I'm not at a command prompt, I'm using
Eclipse to launch ruby, webrick, etc. I suppose I could set it to use the
cygwin interpreter, but I'm not clear if that's going to cause other
problems - e.g. if there are other things that Eclipse/RDT does outside the
cygwin environment that'd confuse it, or if it passes pathnames properly.
So I thought it'd be better if my primary Ruby environment was in win32.
Might have to do with the fact that "which" is not a shell builtin:
better use "type" for that on a bash:

Doh! Yes, that was the problem. Especially because the previous version
of Cygwin's /etc/profile added paths in a suboptimal order, and because
five or six years ago I stuck a DOS version of which.exe in my path.

So I tried running the win32 ruby from cygwin, but it was unhappy - I
forget what errors I ran into. I installed cygwin's version again, and it
almost works, but then I run into the classic shebang problem: all of
ruby's scripts start with (in my case)

#!c:/dev/ruby/bin/ruby

which of course is the wrong ruby to be loading. I can kludge that
particular case by creating a symlink from /usr/local/bin/rake to
c:/dev/ruby/bin/rake.cmd, but that's not a general solution...

Is there any way to override the shebang path with my own ruby, while still
getting one-word access to scripts (e.g. not "ruby rake")? On Linux the
answer is to have scripts use /usr/bin/env instead of a hardcoded path, but
of course that wouldn't exist on Windows either...

Jay
 
R

Robert Klemme

Jay said:
Interesting.. any reason why? When I'm not at a command prompt, I'm using
Eclipse to launch ruby, webrick, etc. I suppose I could set it to use the
cygwin interpreter, but I'm not clear if that's going to cause other
problems - e.g. if there are other things that Eclipse/RDT does outside the
cygwin environment that'd confuse it, or if it passes pathnames properly.
So I thought it'd be better if my primary Ruby environment was in win32.


Doh! Yes, that was the problem. Especially because the previous version
of Cygwin's /etc/profile added paths in a suboptimal order, and because
five or six years ago I stuck a DOS version of which.exe in my path.

So I tried running the win32 ruby from cygwin, but it was unhappy - I
forget what errors I ran into. I installed cygwin's version again, and it
almost works, but then I run into the classic shebang problem: all of
ruby's scripts start with (in my case)

#!c:/dev/ruby/bin/ruby

which of course is the wrong ruby to be loading. I can kludge that
particular case by creating a symlink from /usr/local/bin/rake to
c:/dev/ruby/bin/rake.cmd, but that's not a general solution...

Is there any way to override the shebang path with my own ruby, while still
getting one-word access to scripts (e.g. not "ruby rake")? On Linux the
answer is to have scripts use /usr/bin/env instead of a hardcoded path, but
of course that wouldn't exist on Windows either...

.... but in cygwin. You can set it up this way: have a #! appropriate
for cygwin's use and associate *.rb with the Windows Ruby in Windows. I
use the cygwin only, but then again - I rarely start ruby scripts via
windows programs.

HTH

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top