Question regarding pik/ruby/jRuby

I’m very new with Ruby, and am going through Chris P.'s Learn to
Program
at
the moment. For the hell of it, though, I went ahead and installed
pik/JRuby
so I could play around with an article I read, on building desktop
applications with
JRubyhttp://rubylearning.com/blog/2010/09/29/an-introduction-to-desktop-apps-with-ruby/
.

In the article on desktop apps it tells you to install JRuby through
RVM,
which I can’t. But, since I’m on Windows and just discovered pik, I took
that route, thinking I’d get the same result.

Well I noticed that I had to run my scripts typing jruby
scriptname.rb
whereas
the writer could do it with ruby scriptname.rb, still. I asked how he
does
this and got the response below:

If you are using RVM it creates a ‘ruby’ symlink to jruby (see

~/.rvm/rubies/jruby-1.5.2/). I’m guessing in your case you installed JRuby
by itself which won’t have created the symlink.

I would have thought that pik would do something similar, but I guess
not.

My other problem is that I can’t use jruby at all unless I go into
command
prompt and type *pik use jruby. *If I close command prompt, and open it
again, I have to do it all over. Below is just showing that I have to
pik
use jruby
and once it’s set to Jruby it won’t recognize ruby -v.

C:\Users\Jared>ruby -v

ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

C:\Users\Jared>jruby -v

‘jruby’ is not recognized as an internal or external command,

operable program or batch file.

C:\Users\Jared>pik list

153: jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7)
(Java

HotSpot™ Client VM 1.6.0_21)…

186: ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]

C:\Users\Jared>pik use jruby

C:\Users\Jared>pik list

  • 153: jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7)
    (Java

HotSpot™ Client VM 1.6.0_21)…

186: ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]

C:\Users\Jared>jruby -v

jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7) (Java

HotSpot™ Client VM 1.6.0_21) [x86-java]

C:\Users\Jared>ruby -v

‘ruby’ is not recognized as an internal or external command,

operable program or batch file.

Any thoughts, guys and gals?

Jared Miller

So you don’t feel too left out, pik and RVM do similar things, but yes,
RVM is more powerful (in large part because the Bash command line
environment it lives in is much more powerful).

Both tools provide a method to switch from the default ruby on the
command-line, but outside of a command-line environment, the system
default will always be used, regardless of which tool or OS you’re
using. As Roger suggested, you can edit the PATH variable in Windows to
alter which ruby gets called by default; Windows will execute the first
one it comes to in your PATH. For me, I’d just keep running ‘jruby’ on
Windows, instead of editing the PATH constantly.

Both RVM and pik provide a method for having multiple concurrent
versions of Ruby installed on your computer; both keep a set of gems per
version. However, RVM also provides “gemsets”, which allow you to setup
a global set of gems as well as gems just for a particular project or
use-case. By including a one-line text file in a directory, RVM can be
told to automatically switch to this “gemset”, which sets the default
version of ruby and loads the project-specific gems automatically.

RVM has many, many more features, and it just might be worth installing
an easy-to-use Linux distro just to give it a try.

If you are using RVM it creates a ‘ruby’ symlink to jruby (see

~/.rvm/rubies/jruby-1.5.2/). I’m guessing in your case you installed JRuby
by itself which won’t have created the symlink.

I would have thought that pik would do something similar, but I guess
not.

Yeah unfortunately it doesn’t. You could, however, create a file
“ruby.bat” within your jruby\bin folder that just calls jruby, like:

jruby %*

Then you’d have it.

My other problem is that I can’t use jruby at all unless I go into
command
prompt and type *pik use jruby.

Yeah you can only have one default, which is determined by your system’s
PATH setting. If you were to add your jruby bin folder to the beginning
of your path, you would then have it by default (as jruby). Pik doesn’t
do anything but switch away from the default. The default you must
manually set up (I think, anyway). Another way to set up jruby as a
default is to use their one click installer, and check the “setup my
path for me” button.

GL.
-r

*If I close command prompt, and open it
again, I have to do it all over. Below is just showing that I have to
pik
use jruby
and once it’s set to Jruby it won’t recognize ruby -v.

C:\Users\Jared>ruby -v

ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

C:\Users\Jared>jruby -v

‘jruby’ is not recognized as an internal or external command,

operable program or batch file.

C:\Users\Jared>pik list

153: jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7)
(Java

HotSpot™ Client VM 1.6.0_21)…

186: ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]

C:\Users\Jared>pik use jruby

C:\Users\Jared>pik list

  • 153: jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7)
    (Java

HotSpot™ Client VM 1.6.0_21)…

186: ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]

C:\Users\Jared>jruby -v

jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7) (Java

HotSpot™ Client VM 1.6.0_21) [x86-java]

C:\Users\Jared>ruby -v

‘ruby’ is not recognized as an internal or external command,

operable program or batch file.

Any thoughts, guys and gals?

Jared Miller

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs