iron-io / iron_worker_ruby_ng

Next Gen Ruby gem for IronWorker
www.iron.io
BSD 2-Clause "Simplified" License
58 stars 22 forks source link

Error while uploading Worker files with gems #225

Closed jatindhankhar closed 9 years ago

jatindhankhar commented 9 years ago

I am trying to create a simple worker to make a third party API call, however upload fails if I specify gem in the worker file

Here is my worker file

runtime "ruby"
exec "hello_worker.rb"
gem "rest-client"

Here is my hello_worker.rb

require 'rest-client'
def send_simple_message email_id,name
  RestClient.post "https://api:key-xxxxxxxxxxxxxxxxxxxxxxxxxx"\
        "@api.mailgun.net/v2/xxxxxxx/messages",
          :from => "sender@example.com",
            :to => email_id,
          :subject => "Hello",
            :text => "Hi #{name}, Testing worker calls"

send_simple_message "someone@example.com", "Jatin"

and when I do this iron_worker upload hello I get

Creating client
        Project 'PivotalWebServices - IronWorker' with id='xxxxxxxxxxxxxxxxxxxxxxx'
------> Creating code package
        Found workerfile with path='hello.worker'
        Detected exec with path='hello_worker.rb' and args='{}'
        Adding ruby gem dependency with name='rest-client' and version='>= 0'
        Code package name is 'hello'
------> Uploading code package 'hello'
        Fixating gems dependencies
        Merging ruby gem with name='unf_ext' and version='0.0.7.1'
        Merging ruby gem with name='unf' and version='0.1.4'
        Merging ruby gem with name='domain_name' and version='0.5.24'
        Merging ruby gem with name='http-cookie' and version='1.0.2'
        Merging ruby gem with name='mime-types' and version='2.6.2'
        Merging ruby gem with name='netrc' and version='0.10.3'
        Merging ruby gem with name='rest-client' and version='1.8.0'
/home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/bundler-1.10.3/lib/bundler/lazy_specification.rb:77:in `method_missing': undefined method `extensions' for #<Bundler::LazySpecification:0x00558a8fe269f8> (NoMethodError)
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/lib/iron_worker_ng/feature/ruby/merge_gem.rb:41:in `bundle'
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/lib/iron_worker_ng/code/base.rb:235:in `block in bundle'
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/lib/iron_worker_ng/code/base.rb:234:in `each'
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/lib/iron_worker_ng/code/base.rb:234:in `bundle'
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/lib/iron_worker_ng/code/base.rb:301:in `create_container'
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/lib/iron_worker_ng/client.rb:105:in `codes_create'
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/lib/iron_worker_ng/client.rb:18:in `method_missing'
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/lib/iron_worker_ng/cli.rb:117:in `upload'
    from /home/jatin/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/gems/iron_worker_ng-1.6.6/bin/iron_worker:124:in `<top (required)>'
    from /home/jatin/.rbenv/versions/2.1.6/bin/iron_worker:23:in `load'
    from /home/jatin/.rbenv/versions/2.1.6/bin/iron_worker:23:in `<main>'

But if I do a trivial worker without any gem stuff I works

jatindhankhar commented 9 years ago

It worked I was missing remote option in the worker file. All fine now :+1: Never mind

treeder commented 9 years ago

Hi @jatindhankhar , you might want to try our new Docker based workflow, you can build gems locally and test locally before uploading. https://github.com/iron-io/dockerworker/tree/master/ruby

jatindhankhar commented 9 years ago

Thanks for the link. I tried the new workflow but for some reason uploading was not working (docker images issues , I guess). Will give it another try :+1:

treeder commented 9 years ago

Ok, let us know if you have any issues.

treeder commented 9 years ago

Hit the chat button at the bottom of HUD.