JRuby on Rails won't run on Windows XP - had to adjust rails/lib/initializer.rb

After building JRuby and installing Rails, when I run “jruby -v” the
following version is reported: ruby 1.8.5 (2007-10-15 rev 3876)
[x86-jruby1.1].

Also, I have read Headius: A Ruby in the Rough
which tells me that JRuby always sets the platform to “java”.

Unfortunately, this way there is no indication whether I run JRuby on a
Windows or any other platform. This shouldn’t really matter, because
Java is platform independent, but in the case of rails (or at least when
I want to start the server), it does matter. Otherwise starting the
server would give me:

C:\Work\projects\jrubyonrails>jruby script\server
C:/Programme/Java/jruby/lib/ruby/1.8/pathname.rb:420:in realpath_rec': No such file or directory - C: (Errno::ENOENT) from C:/Programme/Java/jruby/lib/ruby/1.8/pathname.rb:453:in realpath’
from
C:/Programme/Java/jruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/initializ
er.rb:543:in set_root_path!' from C:/Programme/Java/jruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/initializ er.rb:509:in initialize’
from ./script/…/config/boot.rb:38:in new' from ./script/../config/boot.rb:38:in run’
from ./script/…/config/boot.rb:38:in run' from script\server:2:in require’
from script\server:2:in `require’

To make it work, I had to force the following function to properly
identify my platform as Windows.

def set_root_path!
  raise 'RAILS_ROOT is not set' unless defined?(::RAILS_ROOT)
  raise 'RAILS_ROOT is not a directory' unless

File.directory?(::RAILS_ROOT)

  @root_path =
    # Pathname is incompatible with Windows, but Windows doesn't

have
# real symlinks so File.expand_path is safe.
puts RUBY_PLATFORM
if RUBY_PLATFORM =~ /(:?mswin|mingw|java)/
File.expand_path(::RAILS_ROOT)

    # Otherwise use Pathname#realpath which respects symlinks.
    else
      Pathname.new(::RAILS_ROOT).realpath.to_s
    end
end

I know that this is not a solution, just a work-around.

Tobias.

Wolff, Tobias wrote:

Java is platform independent, but in the case of rails (or at least when
I want to start the server), it does matter. Otherwise starting the
server would give me:

See this bug for a list of additional properties that could be used to
detect OS, and let us know if something else is needed:

http://jira.codehaus.org/browse/JRUBY-454

  • Charlie

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

I have been using this little bit of code throughout my application when
I
need to know if I’m windows or not:

APP_PLATFORM = java.lang.System.getProperty(“os.name”)
def windows?
APP_PLATFORM =~ /windows/i
end

I found it simplest to place this code in my environment so that it is
visible to my entire application in both source and test.

I know this won’t immediately help your Rails problem, since the code
you
posted is using RUBY_PLATFORM. But maybe it can help you or someone else
in
the future on other problems.

Hi
For the past couple of days I am running into an issue when installing
“rails” gem into a jruby fresh build from the trunk. The error that I
get is :

gem install rails --no-rdoc --no-ri --include-dependencies
ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find rake (>= 0.7.2) in any repository

This has been running fine until. I know that jruby revision 4571 worked
fine for me. I have not made any changes to my build script in the
meantime.
The platform that I have tried this on is Solaris SPARC.

Thanks
Pramod G.


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Hi Nick
Not sure what happened here. Yesterday I had tried to rerun gem
install 4-5 times and all of them had resulted in the same error that I
had listed earlier.

Well today I tried out the same and it works fine.

I have set up a build script internally on hudson, which runs once a day
and performs the following tasks :
checkout out jruby
run “ant test”
install gems
checkout goldspike plugin
create the Glassfish updatecenter module for Jruby
install the latest Glassfish application build
create a standalone war of the cookbook sample
deploy the sample to glassfish application server
using cookbook webtest run a series of test that would do a list,
insert into cookbook.

Well this has been running for about 2 weeks now. Effective from Oct12,
I have seen this issue on hudson. So yesterday I tried to reproduce this
on my local Solaris x86 machine and ran into the issue that I had
reported. Anyway today it seems to be OK.

Let me see what happens to the hudson build today.

Thanks for Ur help
Pramod

Pramod G. wrote:

Hi Nick
Not sure what happened here. Yesterday I had tried to rerun gem
install 4-5 times and all of them had resulted in the same error that I
had listed earlier.

Well today I tried out the same and it works fine.

That’s a know problem with the source_cache of RubyGems.

Sometimes the copy it get from gems.rubyforge.org is broken, so that
hose the whole donwload/installation of gems until the next cron job (of
index generation).

On 10/15/07, Pramod G. [email protected] wrote:

Hi
For the past couple of days I am running into an issue when installing
“rails” gem into a jruby fresh build from the trunk. The error that I
get is :

gem install rails --no-rdoc --no-ri --include-dependencies
ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find rake (>= 0.7.2) in any repository

Hmm, haven’t heard of this yet. What happens if:

  1. you remove the lib/ruby/gems/1.8/source_cache and try again?
  2. if that doesn’t fix it, what happens if you simply re-run the gem
    install again?

/Nick


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email