gjkliewer / rumbda

Run ruby scripts on aws lambda.
MIT License
106 stars 18 forks source link

Works great until trying to use a gem #13

Closed TSMMark closed 6 years ago

TSMMark commented 6 years ago

Simply trying to follow the example where we write json to file,

File.open(ENV['RUMBDA_RESULT_JSON_FILENAME'], 'w') do |file|
  file.write(JSON.dump({ statusCode: 200, body: '' }))
end

Except bundler can't seem to be able to find json.

{
  "errorMessage": "Command failed: ./ruby_wrapper '{\"key3\":\"value3\",\"key2\":\"value2\",\"key1\":\"value1\"}'\n/var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find json-2.1.0 in any of the sources (Bundler::GemNotFound)\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/spec_set.rb:85:in `map!'\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/spec_set.rb:85:in `materialize'\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/definition.rb:132:in `specs'\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/definition.rb:177:in `specs_for'\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/definition.rb:166:in `requested_specs'\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/environment.rb:18:in `requested_specs'\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:13:in `setup'\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler.rb:122:in `setup'\n\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/setup.rb:18:in `<top (required)>'\n\tfrom /var/task/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'\n\tfrom /var/task/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'\n\tfrom /var/task/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'\n",
  "errorType": "Error",
  "stackTrace": [
    "/var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find json-2.1.0 in any of the sources (Bundler::GemNotFound)",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/spec_set.rb:85:in `map!'",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/spec_set.rb:85:in `materialize'",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/definition.rb:132:in `specs'",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/definition.rb:177:in `specs_for'",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/definition.rb:166:in `requested_specs'",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/environment.rb:18:in `requested_specs'",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/runtime.rb:13:in `setup'",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler.rb:122:in `setup'",
    "\tfrom /var/task/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/setup.rb:18:in `<top (required)>'",
    "\tfrom /var/task/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'",
    "\tfrom /var/task/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'",
    "\tfrom /var/task/ruby/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'",
    "",
    "ChildProcess.exithandler (child_process.js:204:12)",
    "emitTwo (events.js:106:13)",
    "ChildProcess.emit (events.js:191:7)",
    "maybeClose (internal/child_process.js:886:16)",
    "Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)"
  ]
}

If this is a bug please point me in the right direction and I'll have a PR ready in no time

TSMMark commented 6 years ago

There was a problem with my ruby version. Turns out even tho I had 2.2.2 installed, it was only using 1.9.x. Using rbenv when building solved the issue