How to use Gemfile in iron.io worker

111 views Asked by At

I'd like to use gems specified from Gemfile that I uploaded. However, I keep getting

/usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- capybara (LoadError) from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from app.rb:3:in `<main>'

Seems like the code cannot find the required gems. This is my .worker file:

runtime "ruby"
stack "ruby-2.1"

exec "app.rb"

gemfile "Gemfile"

full_remote_build true

My Gemfile:

source "https://rubygems.org"

gem "capybara"
gem "capybara-webkit"

I uploaded my work using this command:

zip -r my_work.zip . ; iron worker upload --zip my_work.zip --name my_work iron/ruby ruby app.rb ; iron worker queue --wait my_work

Thanks in advance.

1

There are 1 answers

2
Travis Reeder On

There's a couple things here:

1) you are using full_remote_build with a .worker file, but then uploading the zip. Those two things don't go together, it's one or the other.

2) Be sure you are vendoring the gems so they are included when you zip them. To vendor: docker run --rm -v "$PWD":/worker -w /worker iron/ruby:dev bundle install --standalone --clean. Then at the top of your script, add: require_relative 'bundle/bundler/setup'.

See the documentation here for more details: https://github.com/iron-io/dockerworker/tree/master/ruby