views:

246

answers:

1

Pik looks great if you're stuck on a windows machine. The only problem is it appears to be set up for a windows command prompt, and I'm using cygwin.
Whenever I try to switch to a different version of ruby in cygwin, it still just uses the default cygwin installation of ruby.
$ pik list
186: ruby 1.8.6 (2009-06-08 patchlevel 369) [i386-mswin32]
187: ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin] *
187: ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mswin32]
191: ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mswin32]

$ pik switch 191

$ pik list
186: ruby 1.8.6 (2009-06-08 patchlevel 369) [i386-mswin32]
187: ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin] *
187: ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mswin32]
191: ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mswin32]

Doesn't seem to matter what I attempt - it always defaults to the cygwin installation. If I test this on a windows command prompt everything works just fine. It's just cygwin getting in the way somehow, and I'll be damned if I'm giving up my cygwin for the crappy XP command line. :}

A: 

So I ditched pik and went with a (what is to me at least) common approach on mac/linux systems. I unzipped the compiled binaries of the various ruby versions I wanted into /tools/ruby. I then wrote a few aliases 'ruby191' etc in my .zshrc that create a symbolic link to the ruby version I want in /tools/current_ruby. Add /tools/current_ruby/bin onto your path before any system installed version of ruby and voila, you're ready to go.
If you want rubygems installed, simply download the rubygems.zip, switch to the version of ruby you want to install the gems under and run ruby setup.rb in the rubygems directory. I've now got four different ruby versions, each with rubygems installed, up and running on my machine.
This obviously only works in cygwin now, as windows doesn't understand symbolic links at all. But poking around a bit, it seems to be working just fine.

bergyman
Most likely, Cygwin is just running the ruby executable listed when you type `which ruby` on the command line. Another way you can do this is to install your different versions of ruby into different directories, then `chroot`-ing into those directories and running ruby from there. That way, Cygwin can't look up the default version of ruby (directories listed in `$PATH` no longer seem to exist while you are in the `chroot` jail).
bta
Yeah, it's just picking up the first ruby in the path. But if you make sure that current_ruby/bin is first in the path, you're good to go. chroot sounds like a decent solution as well.
bergyman
Well why would someone downvote this? This solution has been working fine for me for nearly a month now.
bergyman