Locating .jrubyrc on Windows

I just downloaded JRuby 1.6.5 and am trying out the new configuration
file “.jrubyrc”. Running Windows XP.
If I put this file in my Home directory, it does not seem to be found by
JRuby. If I put the file in the current directory it works.
Now, by “Home directory” I mean the directory pointed to by the
environment variables HOMEDRIVE + HOMEPATH.
If I put the file in the directory pointed to by environment variable
USERPROFILE it also works.

Am I missing something or does JRuby use USERPROFILE instead of
HOMEDRIVE + HOMEPATH when locating “.jrubyrc”?

I know that by default these would point to the same directory but that
is obviously not the case on this computer.

Claus

Is it not possible to have it in the root of the jruby directory? That
would make most sense to me, I think.

HOMEDRIVE + HOMEPATH when locating “.jrubyrc”?

I know that by default these would point to the same directory but that
is obviously not the case on this computer.

Here’s what I get on my Win7 32bit system. Notice that in the jruby call
the version string has picked up that I want to run in 1.9 mode.

C:>cd %USERPROFILE% && type .jrubyrc
compat.version = 1.9

C:\Users\Jon>

C:\Users\Jon>jruby -ve “puts ENV[‘HOME’]; puts ENV[‘USERPROFILE’]; puts
ENV[‘HOMEDRIVE’] + ENV[‘HOMEPATH’]”
jruby 1.6.5 (ruby-1.9.2-p136) (2011-10-25 9dcd388) (Java HotSpot™
Client VM 1.7.0_01) [Windows 7-x86-java]
C:\Users\Jon
C:\Users\Jon
C:\Users\Jon

Odd. Does the .jrubyrc file in your HOME dir actually start with “.”?
Wonderful Explorer regularly reminds me it can’t create dotfiles so I
usually grit my teeth, drop down to cmd.exe and use REN.

Jon


http://thecodeshop.github.com | http://jonforums.github.com/
twitter: @jonforums

For me (and maybe others) it would be very useful to have .jrubyrc in
the jruby directory.

(1) You can carry around exactly the same “ruby” with preferred options.
(2) No need to muck around with environment variables on Windows boxes
or .bashrc on *nixes. Other than adding to path of course.

This could make jruby even more appealing. Ease of use and
transferability are the main reasons I switched, about a year back.

Jon F. wrote in post #1029021:

Here’s what I get on my Win7 32bit system. Notice that in the jruby call
the version string has picked up that I want to run in 1.9 mode.
C:\Users\Jon>jruby -ve “puts ENV[‘HOME’]; puts ENV[‘USERPROFILE’]; puts
ENV[‘HOMEDRIVE’] + ENV[‘HOMEPATH’]”
jruby 1.6.5 (ruby-1.9.2-p136) (2011-10-25 9dcd388) (Java HotSpot™
Client VM 1.7.0_01) [Windows 7-x86-java]
C:\Users\Jon
C:\Users\Jon
C:\Users\Jon

I believe it works on your computer simply because USERPROFILE and
HOMEDRIVE + HOMEPATH points to the same directory, in your case
“C:\Users\Jon”. On my computer, this is not the situation. My “Home”,
that is HOMEDRIVE + HOMEPATH, is pointing to “H:” and my USERPROFILE is
“C:\Documents and Settings\cfb”. These variables are both set by our
administrators i Windows Active Directory and not by me.

It seems that .jrubyrc will not be found via HOMEDRIVE + HOMEPATH but
only via USERPROFILE.

Claus

I believe it works on your computer simply because USERPROFILE and
HOMEDRIVE + HOMEPATH points to the same directory, in your case
“C:\Users\Jon”. On my computer, this is not the situation. My “Home”,
that is HOMEDRIVE + HOMEPATH, is pointing to “H:” and my USERPROFILE is
“C:\Documents and Settings\cfb”. These variables are both set by our
administrators i Windows Active Directory and not by me.

It seems that .jrubyrc will not be found via HOMEDRIVE + HOMEPATH but
only via USERPROFILE.

Given this is how JRuby currently uses the JRE’s ‘user.dir’ and
‘user.home’ properties to search for .jrubyrc
https://github.com/jruby/jruby/blob/master/src/org/jruby/Main.java#L95-130
I wonder if there’s something local you might be able to do to force
lookup to HOMEDRIVE + HOMEPATH.

Running the following on your system doesn’t show “H:” does it?

[‘user.dir’,‘user.home’].each { |i| puts
java.lang.System.get_property(i) }

BTW, here’s something a bit odd:

irb(main):003:0> java.lang.System.set_property ‘user.home’,
‘C:/Users/Jon/Downloads’
=> “C:\Users\Jon”
irb(main):004:0> [‘user.home’, ‘user.dir’].each { |i| puts
java.lang.System.get_property(i) }
C:/Users/Jon/Downloads
C:\Users\Jon\Documents
=> [“user.home”, “user.dir”]

I can guess, but since you have the ability to put a .jrubyrc in your
local USERPROFILE dir, why is HOMEDRIVE + HOMEPATH important to what you
want to do?

Jon


http://thecodeshop.github.com | http://jonforums.github.com/
twitter: @jonforums

Jon F. wrote in post #1029400:

I can guess, but since you have the ability to put a .jrubyrc in your
local USERPROFILE dir, why is HOMEDRIVE + HOMEPATH important to what you
want to do?

I could obviously put it in the USERPROFILE directory but given that
“.gemrc”, “.irbrc”, “.cvsrc”, “_vimrc”, .gitconfig" and other
configuration files are all located in HOMEDRIVE + HOMEPATH this seems
to be the “right” place.

Also, the Microsoft documentation says that

HOMEDRIVE: Returns which local workstation drive letter is connected to
the user’s home directory. Set based on the value of the home directory.
The user’s home directory is specified in Local Users and Groups.

HOMEPATH: Returns the full path of the user’s home directory. Set based
on the value of the home directory. The user’s home directory is
specified in Local Users and Groups.

USERPROFILE: Returns the location of the profile for the current user.

Claus

Is it not possible to have it in the root of the jruby directory? That
would make most sense to me, I think.

Are you saying you’d like it if .jrubyrc could also live in the root of
a JRuby installation directory?

That sounds a bit risky to being accidently deleted during a JRuby
upgrade cycle and potentially has odd property override behaviors. For
example, I wouldn’t want a .jrubyrc in my JRuby install dir to
add/override the .jrubyrc in my home dir. To me, .jrubyrc in the JRuby
install dir on Windows just doesn’t feel the same as a system config
file in /etc on *nix systems.

I prefer .jrubyrc’s current implementation (current dir or a users home
dir) but haven’t yet tried how .jrubyrc in the current dir
adds/overrides .jrubyrc settings from a home dir.

Jon


http://thecodeshop.github.com | http://jonforums.github.com/
twitter: @jonforums

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