rails/rails — Issue #4368: Problem w/ sprockets assets tasks and rails3-maven-plugin
Author: svoynow-lz
Created: 2012-01-06 22:57:27+00:00
State: open

The rails3-maven-plugin (very useful for JRuby projects - https://github.com/torquebox/jruby-maven-plugins/tree/master/rails3-maven-plugin) allows you to run rake tasks in your maven build. It generally works like a charm, but the way that the sprockets assets tasks spawn ruby interpreters seems to break it.

As far as I can tell this plugin is trying very hard to make no assumptions about the environment it is running in, so it's trying to run jruby and rake out of the jruby jars that it knows it has (not assuming there's a rails or rake executable on the path).

So the way it invokes the initial rake task (assets:precompile), is equivalent to this:

java -Xbootclasspath/a:jruby-complete-1.6.5.jar org.jruby.Main -e
"load('jar:file:/Users/svoynow/.m2/repository/de/saumya/mojo/ruby-tools/0.28.6/ruby-tools-0.28.6.jar!/META-INF/jruby.home/bin/rake')"
-- assets:precompile

When this task tries to spawn another ruby to run the subtasks with the appropriate RAILS_ENV etc, at
https://github.com/rails/rails/blob/master/actionpack/lib/sprockets/assets.rake line 5, the value of $0 turns out to be "-e" which causes an error:

[WARNING] file:/Users/svoynow/.m2/repository/org/jruby/jruby-complete/1.6.5/jruby-complete-1.6.5.jar!/META-INF/jruby.home/bin/jruby -e assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
[WARNING] SyntaxError: -e:1: syntax error, unexpected ':'
[WARNING]
[WARNING] assets:precompile:all

(I believe this is an error from the shell)

I'm not sure what can/should be done about this, but it seemed worth pointing out that these rake tasks are making assumptions about how rake is being invoked that aren't always true.

Anybody have any brilliant ideas?

Cheers,

Sasha