ENV should not be case-sensitive on Windows
-------------------------------------------
Key: JRUBY-1441
URL: http://jira.codehaus.org/browse/JRUBY-1441
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.0.1
Environment: Windows XP, Windows 2003
Reporter: Matt Burke
Priority: Minor
On Windows, MRI treats ENV names case-insensitively, and JRuby treats them
case-sensitively. Also, I noticed that JRuby's ENV is a Hash, while MRI uses an
Object.
Here's an example of the difference between MRI and JRuby:
{noformat}
C:\>set my_env=123
C:\>irb
irb(main):001:0> ENV.class
=> Object
irb(main):002:0> ENV['my_env']
=> "123"
irb(main):003:0> ENV['MY_ENV']
=> "123"
irb(main):004:0> quit
C:\>jruby -S irb
irb(main):001:0> ENV.class
=> Hash
irb(main):002:0> ENV['my_env']
=> "123"
irb(main):003:0> ENV['MY_ENV']
=> nil
irb(main):004:0> quit
{noformat}
This causes a problem for us because our Windows build server lowercases all
environment variables before it passes them to ruby, so "OS" is "os", and the
following doesn't work:
{noformat}
if RUBY_PLATFORM =~ /(:?mswin|mingw)/ || (RUBY_PLATFORM == 'java' && ENV['OS']
=~ /windows/i)
File.expand_path(::RAILS_ROOT)
# Otherwise use Pathname#realpath which respects symlinks.
else
Pathname.new(::RAILS_ROOT).realpath.to_s
end
{noformat}
We've worked around it by doing this:
{noformat}
if RUBY_PLATFORM =~ /(:?mswin|mingw)/ || (RUBY_PLATFORM == 'java' && (ENV['OS']
|| ENV['os']) =~ /windows/i)
File.expand_path(::RAILS_ROOT)
# Otherwise use Pathname#realpath which respects symlinks.
else
Pathname.new(::RAILS_ROOT).realpath.to_s
end
{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email