googleads / google-api-ads-ruby

Ad Manager SOAP API Client Libraries for Ruby
297 stars 229 forks source link

cannot load such file -- ads_savon #74

Closed kcore closed 9 years ago

kcore commented 9 years ago

the latest version of the adwords_api gem (> 0.17.0) which now uses google-ads-savon instead of the standard savon gem doesn't seem to work. We have a standard 3.2.11 rails app with nginx and passenger enabled. The application boots up fine with the webrick server, but the moment we put it behind passenger, it gives the standard passenger error (Web application could not be started).

No such file to load -- ads_savon (LoadError)
  vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
  vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:312:in `depend_on'
  vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:225:in `require_dependency'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:438:in `each'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:438:in `block in eager_load!'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:436:in `each'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/engine.rb:436:in `eager_load!'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
  vendor/bundle/ruby/2.0.0/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
  config/environment.rb:4:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  vendor/bundle/ruby/2.0.0/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_eval'
  vendor/bundle/ruby/2.0.0/gems/rack-1.4.7/lib/rack/builder.rb:51:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:112:in `eval'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:28:in `<main>'

the normal rails console and everything works fine with ads_savon being available in it and api working fine.

I tried doing require "ads_savon" in config/application.rb then the passenger throws the following error:

cannot load such file -- ads_savon (LoadError)
  config/application.rb:1:in `require'
  config/application.rb:1:in `<top (required)>'
  config/environment.rb:2:in `require'
  config/environment.rb:2:in `<top (required)>'
  config.ru:3:in `require'
  config.ru:3:in `block in <main>'
  vendor/bundle/ruby/2.0.0/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_eval'
  vendor/bundle/ruby/2.0.0/gems/rack-1.4.7/lib/rack/builder.rb:51:in `initialize'
  config.ru:1:in `new'
  config.ru:1:in `<main>'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:112:in `eval'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:112:in `preload_app'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/local/rvm/gems/ruby-2.0.0-p353/gems/passenger-4.0.37/helper-scripts/rack-preloader.rb:28:in `<main>'

Not able to figure out what the issue is - load sequence of the passenger rack pre_loader... or what?

mcloonan commented 9 years ago

I hate to ask the obvious question, but have you installed the new google-ads-savon gem from Rubygems?

If so, are you able to successfully make API calls from outside of your rails framework, just using google-adwords-api, google-ads-common, and google-ads-savon?

kcore commented 9 years ago

@mcloonan google-ads-savon being a dependency of ads_common, is installed by default. I even went ahead and specifically mentioned it in my Gemfile. Like i said, if i fire up my rails console, and say require "ads_savon" it works. The api works too.

bjminihan commented 9 years ago

+1...I got around the issue by reverting everything to v201406, but then needed data only available in v201509

Running rails 4.2.3 on ruby 2.1.5 on either passenger or puma (tried both), with many variants of this in my gemfile: gem 'google-ads-savon', '~> 1.0' gem 'google-ads-common' gem 'google-adwords-api'

Tried with and without ads-savon and ads-common. Adding require 'adwords_api' in a module prevents the app from spinning up (exact error above), whereas removing the require line throws a NameError: uninitialized constant GoogleAdwordsApi::AdwordsApi error.

I'm finally up against this, as I did everything I could in the older API, but now need to push with the newer - would have said something earlier, but I thought it was my ineptitude =]

mcloonan commented 9 years ago

Since you've confirmed that ads_savon works without your additional framework, I don't think there's much we can do to help here. It must be a configuration issue with your framework, which is not something we can fix within our library.

ads_savon is identical in functionality to the old savon gem we were using before, simply renamed and dependencies updated to avoid compatibility issues with newer versions of savon.

If you are able to figure out what configuration changes you need to make to get this working, please do post here so that we can have some record of it for others who may run into this issue.

dterror-zz commented 9 years ago

We've run into the same issue and actually found the root cause:

The latest version of the gem files uploaded to rubygems.org have a strange umask without read permissions to 'others':

heavy_check_mark: ~/Downloads/google-ads-savon-1.0.0/lib/ads_savon
14:51 $ ls -alh
total 80
drwxr-xr-x  15 foo  staff   510B 17 Nov 11:41 .
drwxr-xr-x   4 foo  staff   136B 17 Nov 11:41 ..
-rw-r-----   1 foo  staff   5.4K 17 Nov 11:41 client.rb
-rw-r-----   1 foo  staff   905B 17 Nov 11:41 config.rb
drwxr-xr-x   3 foo  staff   102B 17 Nov 11:41 core_ext
-rw-r-----   1 foo  staff   104B 17 Nov 11:41 error.rb
drwxr-xr-x   4 foo  staff   136B 17 Nov 11:41 hooks
drwxr-xr-x   3 foo  staff   102B 17 Nov 11:41 http
-rw-r-----   1 foo  staff   905B 17 Nov 11:41 log_message.rb
-rw-r-----   1 foo  staff   603B 17 Nov 11:41 logger.rb
-rw-r-----   1 foo  staff   2.6K 17 Nov 11:41 model.rb
-rw-r-----   1 foo  staff   113B 17 Nov 11:41 null_logger.rb
drwxr-xr-x   8 foo  staff   272B 17 Nov 11:41 soap
-rw-r-----   1 foo  staff   392B 17 Nov 11:41 soap.rb
-rw-r-----   1 foo  staff    93B 17 Nov 11:41 version.rb

This problem is not present if you clone the repository. The fix would involve re-uploading the .gem file to rubygems.org with the fixed permissions.

bjminihan commented 9 years ago

Makes sense in a production environment where gems are deployed and owned by root but run by a web account. Confirmed that adding go+r in prod "solved" the problem, at least for now.

kcore commented 9 years ago

it works if we clone the git repo. @dterror thanks for fix! @mcloonan can we update .gem file so that others don't face the same issue?

mcloonan commented 9 years ago

I will look into this today.

mcloonan commented 9 years ago

I pushed a new version of the ads_savon gem (1.0.1) to RubyGems. Please let me know if this solves the issue.

bjminihan commented 9 years ago

Works on elastic beanstalk...thanks!

jorgeto86 commented 8 years ago

Hello!

Although the ads_savon gem has been updated with this fix, the gem google-ads-common still has the fixed dependency google-ads-savon v 1.0.0 and we are having this issue and can't update to adwords_api gem v 0.17.0. When will the dependencies of google-ads-common be updated?

Thanks!

mcloonan commented 8 years ago

You can still use google-ads-savon v 1.0.1 with the current version of google-ads-common; just manually install the new one and remove the old one.

The next version of ads-common will update the dependency as well.

jorgeto86 commented 8 years ago

I will do so ;)

Thanks!