Rails console from deployed war, with git gems

Hello,

I’m tring to launch a rails console using only the components from my
deployment war similar to the approach described here:

http://www.ruby-forum.com/topic/215432#1005929
http://blog.jonbettcher.com/2010/11/invoking-console-from-deployed-jruby.html

However, I have two :git-based gems in my Gemfile that don’t seem to
work with the examples above. Those gems are bundled in
vendor/bundle/jruby/1.8/bundler/gems instead of just
vendor/bundle/jruby/1.8/gems. Then, warbler places them in
WEB-INF/gems/bundler/gems instead of just WEB-INF/gems/gems. (Why
doesn’t warbler just build the gems first, then package them all the
same way?)

None of the :git gems are found when I try to start a console.
But, my application works from Tomcat so I must be doing something wrong
with my command line paths.

Here’s how I deploy MyApp:

jruby -S bundle install --deployment #–binstubs --standalone
jruby -S bundle exec rake war #No config/warble.rb features, but tried
gemjar
cp MyApp.war $CATALINA_HOME/webapps/.

When I try to execute a rails console I get the following error:

cd $CATALINA_HOME/webapps/MyApp/WEB-INF

java -jar lib/jruby-complete-1.6.7.2.jar script/rails console
LoadError: no such file to load – bundler/setup
require at org/jruby/RubyKernel.java:1033
require at
file:/opt/Tomcat/webapps/MyApp/WEB-INF/lib/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
(root) at /opt/Tomcat/webapps/MyApp/WEB-INF/config/boot.rb:6
require at org/jruby/RubyKernel.java:1033
(root) at script/rails:5

GEM_PATH=gems java -jar lib/jruby-complete-1.6.7.2.jar script/rails
console
/opt/Tomcat/webapps/MyApp/rails (at 3-1-backported) is not checked out.
Please run bundle install

GEM_PATH=gems:gems/bundler java -jar lib/jruby-complete-1.6.7.2.jar
script/rails console
/opt/Tomcat/webapps/MyApp/rails (at 3-1-backported) is not checked out.
Please run bundle install

My Gemfile contains the following line:
gem ‘rails’, :git => File.expand_path(’…/…/rails’, FILE),
:branch => ‘3-1-backported’ #Local git repo with a few rails 3.2.*
features backported to 3.1-stable

I’m wondering why my application works from Tomcat, but not at the
command line.

Thanks in advance for any advice.

Hi Tom,

Appreciate your work!

We have the same problem (well roughly) - did you get a solution?

Adam.

Scratch that; it doesn’t work from Tomcat either. I’ve since updated to
the bundler 1.2 rc2 (which is supposed to be able to package :git gems)
but that doesn’t work either.

My new plan is to roll my own rake task to just pre-build all of the
gems prior to running warble. Unfortunately, I ran into the same kinds
of issues just trying to install rails from source (rails relies on a
:git hosted version of the sdoc gem).

bash-3.2$ cd rails #my local :git repo cloned from 3-1-stable
bash-3.2$ jruby -S bundle exec rake -T
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/source.rb:801:in
load_spec_files': git://github.com/fxn/sdoc.git (at master) is not checked out. Please runbundle install(Bundler::GitError) from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/source.rb:381:inlocal_specs’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/source.rb:774:in
specs' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:178:inresolve’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:176:in
each' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:176:inresolve’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:113:in
specs' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:162:inspecs_for’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:151:in
requested_specs' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/environment.rb:23:inrequested_specs’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/runtime.rb:11:in
setup' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler.rb:116:insetup’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/setup.rb:17

So bundler says to lease run bundle install ok…

bash-3.2$ jruby -S bundle install
Using rake (0.9.2.2)
Using RedCloth (4.2.9)
Using multi_json (1.2.0)
Using activesupport (3.1.6) from source at .
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.6) from source at .
Using erubis (2.7.0)
Using rack (1.3.6)
Using rack-cache (1.2)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.4)
Using actionpack (3.1.6) from source at .
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.3)
Using actionmailer (3.1.6) from source at .
Using arel (2.2.3)
Using tzinfo (0.3.33)
Using activerecord (3.1.6) from source at .
Using activerecord-jdbc-adapter (1.2.2)
Using jdbc-mysql (5.1.13)
Using activerecord-jdbcmysql-adapter (1.2.2)
Using jdbc-postgres (9.1.901)
Using activerecord-jdbcpostgresql-adapter (1.2.2)
Using jdbc-sqlite3 (3.7.2)
Using activerecord-jdbcsqlite3-adapter (1.2.2)
Using activeresource (3.1.6) from source at .
Using bcrypt-ruby (3.0.1)
Using bouncy-castle-java (1.5.0146.1)
Using bundler (1.2.0.rc.2)
Using execjs (1.4.0)
Using rack-ssl (1.3.2)
Using json (1.7.4)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.1.6) from source at .
Using jquery-rails (2.0.3)
Using jruby-openssl (0.7.7)
Using json_pure (1.7.4)
Using memcache-client (1.8.5)
Using metaclass (0.0.1)
Using mocha (0.10.5)
Using nokogiri (1.5.5)
Using rails (3.1.6) from source at .
Using sdoc (0.3.15) from git://github.com/fxn/sdoc.git (at master)
Using uglifier (1.2.4)
Using w3c_validators (1.2)
Your bundle is complete! Use bundle show [gemname] to see where a
bundled gem is installed.

Now to try again…

bash-3.2$ jruby -S bundle exec rake -T
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/source.rb:801:in
load_spec_files': git://github.com/fxn/sdoc.git (at master) is not checked out. Please runbundle install(Bundler::GitError) from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/source.rb:381:inlocal_specs’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/source.rb:774:in
specs' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:178:inresolve’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:176:in
each' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:176:inresolve’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:113:in
specs' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:162:inspecs_for’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:151:in
requested_specs' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/environment.rb:23:inrequested_specs’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/runtime.rb:11:in
setup' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler.rb:116:insetup’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/setup.rb:17

So, bundler isn’t even self-consistent with its own instructions. (Why
doesn’t bundler check the location where it installs gems before
complaining that a gem isn’t installed?)

If I use deployment mode, bundler is able to find the gems it
installs:

bash-3.2$ jruby -S bundle install --deployment
Fetching gem metadata from http://rubygems.org/
Fetching git://github.com/fxn/sdoc.git
Installing rake (0.9.2.2)
Installing RedCloth (4.2.9)
Installing multi_json (1.2.0)
Using activesupport (3.1.6) from source at .
Installing builder (3.0.0)
Installing i18n (0.6.0)
Using activemodel (3.1.6) from source at .
Installing erubis (2.7.0)
Installing rack (1.3.6)
Installing rack-cache (1.2)
Installing rack-mount (0.8.3)
Installing rack-test (0.6.1)
Installing hike (1.2.1)
Installing tilt (1.3.3)
Installing sprockets (2.0.4)
Using actionpack (3.1.6) from source at .
Installing mime-types (1.19)
Installing polyglot (0.3.3)
Installing treetop (1.4.10)
Installing mail (2.3.3)
Using actionmailer (3.1.6) from source at .
Installing arel (2.2.3)
Installing tzinfo (0.3.33)
Using activerecord (3.1.6) from source at .
Installing activerecord-jdbc-adapter (1.2.2)
Installing jdbc-mysql (5.1.13)
Installing activerecord-jdbcmysql-adapter (1.2.2)
Installing jdbc-postgres (9.1.901)
Installing activerecord-jdbcpostgresql-adapter (1.2.2)
Installing jdbc-sqlite3 (3.7.2)
Installing activerecord-jdbcsqlite3-adapter (1.2.2)
Using activeresource (3.1.6) from source at .
Installing bcrypt-ruby (3.0.1)
Installing bouncy-castle-java (1.5.0146.1)
Installing execjs (1.4.0)
Installing rack-ssl (1.3.2)
Installing json (1.7.4)
Installing rdoc (3.12)
Installing thor (0.14.6)
Using railties (3.1.6) from source at .
Installing jquery-rails (2.0.3)
Installing jruby-openssl (0.7.7)
Installing json_pure (1.7.4)
Installing memcache-client (1.8.5)
Installing metaclass (0.0.1)
Installing mocha (0.10.5)
Installing nokogiri (1.5.5)
Using bundler (1.2.0.rc.2)
Using rails (3.1.6) from source at .
Using sdoc (0.3.15) from git://github.com/fxn/sdoc.git (at master)
Installing uglifier (1.2.4)
Installing w3c_validators (1.2)
Your bundle is complete! It was installed into ./vendor/bundle
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri
data:

<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install

= 1.9.2 : nothing to do! Yay!

Now to try again…

bash-3.2$ jruby -S bundle exec rake -T
rake build # Build gem files for all projects
rake clobber_rdoc # Remove RDoc HTML files
rake default # Run all tests by default
rake gem # Run gem task for all projects
rake install # Install gems for all projects.
rake package # Run package task for all projects
rake publish_docs # Publishes docs, run this AFTER a new stable tag
has been pushed
rake rdoc # Build RDoc HTML files
rake release # Release all gems to gemcutter and create a tag
rake rerdoc # Rebuild RDoc HTML files
rake smoke # Smoke-test all projects
rake test # Run test task for all projects
rake test:isolated # Run test:isolated task for all projects
rake update_versions # Bump all versions to match version.rb

Success!!
Now to build rails…

bash-3.2$ jruby -S bundle exec rake build
rm -f dist/activesupport-3.1.6.gem
cd activesupport && gem build activesupport.gemspec && mv
activesupport-3.1.6.gem /T2/rails/dist/
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/spec_set.rb:90:in
materialize': Could not find rake-0.9.2.2 in any of the sources (Bundler::GemNotFound) from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/spec_set.rb:83:inmap!’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/spec_set.rb:83:in
materialize' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:113:inspecs’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:162:in
specs_for' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:151:inrequested_specs’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/environment.rb:23:in
requested_specs' from /opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/runtime.rb:11:insetup’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler.rb:116:in
`setup’
from
/opt/local/share/java/jruby/lib/ruby/gems/1.8/gems/bundler-1.2.0.rc.2/lib/bundler/setup.rb:17
rake aborted!
Command failed with status (1): [cd activesupport && gem build
activesuppor…]

Tasks: TOP => build => all:build => activesupport:build =>
activesupport:dist/activesupport-3.1.6.gem
(See full trace by running task with --trace)

And we get a new bundler error. (I think I spend more time
troubleshooting Bundler than all other aspects of my project
combined…)

Any advise is much appreciate.

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