jruby 1.7.0.preview1 (ruby-1.9.3-p203) (2012-05-19 00c8c98) (Java
HotSpot™ 64-Bit Server VM 1.7.0_05) [linux-amd64-java]
Installed with RVM.
Setting up a simple Procfile and Ruby code (just does a puts every 10
seconds) to run with Foreman, with plans to try and deploy it to Heroku
(just testing out how it all works).
I run “foreman start” and get the following error:
foreman start
LoadError: load error: posix_spawn_ext – java.lang.RuntimeException:
invalid ruby runtime
require at org/jruby/RubyKernel.java:991
require at
/home/mark/.rvm/rubies/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:2
require at org/jruby/RubyKernel.java:991
require at
/home/mark/.rvm/rubies/jruby-1.7.0.preview1/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/foreman-0.51.0-java/lib/foreman/process.rb:1
chdir at org/jruby/RubyDir.java:466
run at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/foreman-0.51.0-java/lib/foreman/process.rb:47
run at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/foreman-0.51.0-java/lib/foreman/process.rb:46
upto at org/jruby/RubyInteger.java:139
spawn_processes at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/foreman-0.51.0-java/lib/foreman/engine.rb:259
each at org/jruby/RubyArray.java:1611
spawn_processes at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/foreman-0.51.0-java/lib/foreman/engine.rb:256
spawn_processes at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/foreman-0.51.0-java/lib/foreman/engine.rb:255
start at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/foreman-0.51.0-java/lib/foreman/engine.rb:45 send at org/jruby/RubyBasicObject.java:1786
send at org/jruby/RubyKernel.java:1990
start at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/foreman-0.51.0-java/lib/foreman/cli.rb:40
run at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/thor-0.15.4/lib/thor/task.rb:27
invoke_task at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/thor-0.15.4/lib/thor/invocation.rb:120
dispatch at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/thor-0.15.4/lib/thor.rb:275
start at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/gems/thor-0.15.4/lib/thor/base.rb:425
load at org/jruby/RubyKernel.java:1017
(root) at
/home/mark/.rvm/gems/jruby-1.7.0.preview1/bin/foreman:23
Honestly - not quite sure what to do here. Fairly new to J/Ruby, so is
it
even possible to run Foreman with JRuby? It looked like it was from the
source.
You get the “invalid ruby runtime” error when trying to use a library
containing C extensions under JRuby from more than one JRuby runtime.
Foreman depends on posix-spawn under JRuby, and posix-spawn has a native
component.
The real question is why are multiple JRuby runtimes involved when
running foreman start.
Thanks for your response, but I’m confused by some things.
If the issue is the posix-spawn having native extensions, how come it’s
only added as a dependency when the platform is Java:
Or are you saying that posix-spawn has somehow been installed with the
extensions, and therefore when I try and use it from JRuby, it all goes
pear shaped?
Thanks for your help!
Mark
On Tue, Jul 24, 2012 at 11:54 PM, Benjamin B. [email protected]wrote:
The posix-spawn dependency is only added under JRuby because reliably
spawning a subprocess and reading reading its output and error streams
is harder than you’d expect under JRuby.
So the author of foreman likely uses posix-spawn to not worry about
dealing with this directly, instead delegating those details to
posix-spawn. The issue is posix-spawn’s JRuby support still uses a C
extension. So, while it works under JRuby, it won’t work if it gets
loaded from more than one JRuby runtime within the same JVM which is
apparently what’s happening.
I just had a coworker who just has a plain JRuby install, and he tried
the
same thing - same error. So it doesn’t sound like it’s a bug regarding
RVM,
it sounds like a legitamate bug with foreman.
I think I’ll just submit a bug on Github, and see where that gets me.
Thanks for your help though!
When I was referring to JRuby runtime below I mean that some code is
spinning up more than one instance of the org.jruby.Ruby class within
the same JVM. If you’re code is not doing this explicitly and foreman is
not doing this explicitly then it may be happening implicitly - if JRuby
detects a command that shells out to Ruby then by default I believe it
intercepts those commands and runs them in a new JRuby runtime within
the same JVM versus firing up a new JVM.
So I was looking into this further, and I think the issue about spinning
up
more than one instance of Jruby was fixed several versions back: http://jira.codehaus.org/browse/JRUBY-5044
From the ticket, the following command works with no problem:
jruby --1.9 -e ‘x = spawn “jruby -e sleep”; p x’
This looks to be something else entirely different.
It looks to be falling over on this line:
Which leads me to believe it’s an issue with C extensions not working,
but
that is outside my area of expertise.
Or are you saying that something in my code is loading up JRuby more
spawning a subprocess and reading reading its output and error
JRuby runtime within the same JVM which is apparently what’s
only added as a dependency when the platform is Java:
Mark