Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment: uninitialized constant ActiveShipping::Base #26

Closed
w0lver opened this issue Apr 17, 2012 · 24 comments
Closed

Deployment: uninitialized constant ActiveShipping::Base #26

w0lver opened this issue Apr 17, 2012 · 24 comments

Comments

@w0lver
Copy link

w0lver commented Apr 17, 2012

Tried deploying an app in development to production on both Heroku and a clean install CentOS and I'm getting the same issue.
Using RVM, Ruby 1.9.2p318, Rails 2.3.2. The Spree version is the 1.1 beta. Replication is fairly simple check project into github and then try to deploy on Heroku. The push to Heroku works, its when you try to run rake to create or migrate the DB is where it error out.

Here's the error:
rake aborted!
uninitialized constant ActiveShipping::Base

No very helpful.

@radar
Copy link
Contributor

radar commented Apr 17, 2012

I think you mean Rails 3.2.3

@radar
Copy link
Contributor

radar commented Apr 17, 2012

spree_active_shipping also install alongside 1.1 beta, and so I don't know how you got this to work.

@radar
Copy link
Contributor

radar commented Apr 17, 2012

I just fixed the spree_active_shipping issue with this commit: 80387e4

... except that now active_shipping breaks with undefined method class_inheritable_accessor.

LE SIGH.

@w0lver
Copy link
Author

w0lver commented Apr 17, 2012

yes, you are correct, got a dyslexic on the version, it is 3.2.3.

So I've update my Gemfile to pull from git now.

Is your checkin just to fix the dependency information?

@radar
Copy link
Contributor

radar commented Apr 17, 2012

I've updated the README for spree_active_shipping to now specify that you should include active_shipping gem from Git, rather than relying on spree_active_shipping to pull it in, because the Git repo for active_shipping has been updated way more recently than the gem has.

Could you try doing what the README now recommends and let us know how that goes? Thanks.

@w0lver
Copy link
Author

w0lver commented Apr 17, 2012

Getting the same error...

Spree section of Gemfile:

Gems for Spree Commerce

gem 'spree', :path => 'gems/spree'
gem 'spree_gateway', :path => 'gems/spree_gateway'
gem 'active_shipping', :git => "git://github.com/Shopify/active_shipping"
gem 'spree_active_shipping', :git => "git://github.com/spree/spree_active_shipping"

@radar
Copy link
Contributor

radar commented Apr 17, 2012

rake aborted!
uninitialized constant ActiveShipping::Base

Boom! I'm getting it too on Heroku. FUN!

@radar
Copy link
Contributor

radar commented Apr 17, 2012

This is probably fixed with @8c68d887d73727ad435bf5b34797bebd52683eba. I'm just testing it on Heroku now.

@radar
Copy link
Contributor

radar commented Apr 17, 2012

Nope, not fixed. Seems like active_shipping has changed quite a bit.

@w0lver
Copy link
Author

w0lver commented Apr 17, 2012

I'm guessing you see what I see:
rake aborted!
wrong argument type Module (expected Class)

Let me know if I can help in any way

@radar
Copy link
Contributor

radar commented Apr 17, 2012

Ok, now I think it's really fixed with @09763f7. Please let us know how things go.

@w0lver
Copy link
Author

w0lver commented Apr 17, 2012

Just tried it, back the the original error:
rake aborted!
uninitialized constant ActiveShipping::Base
Here's the trace:

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant ActiveShipping::Base
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/app/models/spree/calculator/fedex/base.rb:4:in `<module:Fedex>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/app/models/spree/calculator/fedex/base.rb:3:in `<class:Calculator>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/app/models/spree/calculator/fedex/base.rb:2:in `<module:Spree>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/app/models/spree/calculator/fedex/base.rb:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/app/models/spree/calculator/fedex/one_day_freight_saturday_delivery.rb:4:in `<module:Fedex>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/app/models/spree/calculator/fedex/one_day_freight_saturday_delivery.rb:3:in `<class:Calculator>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/app/models/spree/calculator/fedex/one_day_freight_saturday_delivery.rb:2:in `<module:Spree>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/app/models/spree/calculator/fedex/one_day_freight_saturday_delivery.rb:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/lib/spree_active_shipping/engine.rb:25:in `block (2 levels) in <class:Engine>'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/lib/spree_active_shipping/engine.rb:24:in `glob'
/app/.bundle/gems/ruby/1.9.1/bundler/gems/spree_active_shipping-09763f791078/lib/spree_active_shipping/engine.rb:24:in `block in <class:Engine>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/config/environment.rb:5:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:103:in `require_environment!'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/ruby1.9.2/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/ruby1.9.2/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/bin/rake:19:in `load'
/app/.bundle/gems/ruby/1.9.1/bin/rake:19:in `<main>'
Tasks: TOP => db:migrate => environment

@radar
Copy link
Contributor

radar commented Apr 17, 2012

This problem is because of the non-deterministic load order on your system which is produced by Dir.glob. Programmers tend to use Dir.glob when they want a list of files, but don't realise that by using it in conjunction with require, you may end up getting files loaded that depend on other files being loaded first.

This is what was happening. Heroku and CentOS machines load it in non-deterministic orders. Therefore we need to sort and then load, or alternatively require the class-defining file at the top of the class. I've gone with sort here, as that's easiest.

I think this is really truly fixed now in @b6ee9b55b8f8a4068d4c77700b43a1fde6e97f72. The last "fix" was because it worked on Heroku the first time I tried it, and so I honestly thought it fixed it.

This time I'm sure.

@radar radar closed this as completed Apr 17, 2012
@w0lver
Copy link
Author

w0lver commented Apr 17, 2012

we're good. Thanks!

@radar
Copy link
Contributor

radar commented Apr 17, 2012

Success! Great to hear :)

@jclay
Copy link

jclay commented Apr 18, 2012

It doesn't seem to be working for me, I'm still getting this error:

/var/www/jdhnutrition/shared/bundle/ruby/1.9.1/bundler/gems/spree_active_shipping-b6ee9b55b8f8/app/models/spree/calculator/ups/base.rb:2: warning: toplevel constant ActiveShipping referenced by Spree::Calculator::ActiveShipping
Exiting
/var/www/jdhnutrition/shared/bundle/ruby/1.9.1/bundler/gems/spree_active_shipping-b6ee9b55b8f8/app/models/spree/calculator/ups/base.rb:2:in `<module:Spree>': uninitialized constant ActiveShipping::Base (NameError)

@radar
Copy link
Contributor

radar commented Apr 18, 2012

@jclay Please provide more information as to how you're getting this error please. Include Spree version, output of bundle show spree_active_shipping and steps to reproduce the issue from a bare Spree installation. Thank you.

@jclay
Copy link

jclay commented Apr 18, 2012

I would be glad to!

bundle show spree_active_shipping yields:

/usr/local/rvm/gems/ruby-1.9.2-p318@jdhnew/bundler/gems/spree_active_shipping-b6ee9b55b8f8

I'm also running spree 1.0.3. This environment works fine when I'm running on my local development machine, however when I push to my deployment VPS and run bundle install/update and try to run rails s, I get the uninitialized constant ActiveShipping::Base (NameError) error.

@iloveitaly
Copy link
Member

I was getting this error as well. Changing line 24:

 Dir.glob(File.join(File.dirname(__FILE__), "../../app/models/spree/calculator/**/*.rb")) do |c|

to:

Dir[File.join(File.dirname(__FILE__), "../../app/models/spree/calculator/**/*.rb")].sort.each do |c|

Fixed the issue.

@radar
Copy link
Contributor

radar commented Apr 18, 2012

Oh geez, there's more than one?! One moment.

@radar
Copy link
Contributor

radar commented Apr 18, 2012

Fixed in ^. Thanks @iloveitaly!

@jclay
Copy link

jclay commented Apr 19, 2012

Working perfectly now. Thanks @radar and @iloveitaly

@nhunzaker
Copy link

How does this look in Spree 0.70.x? I'm still getting the error when deploying.

@radar
Copy link
Contributor

radar commented Apr 30, 2012

It is still most likely broken for that version. We are no longer officially supporting 0.70 now that 1.1 is out. Our support policy is new feature development & bug fixes on the current master branch, all bug fixes on the latest stable branch and serious bug fixes on the third oldest version.

If you would like this extension to work on 0.70 you will need to fork it and patch it yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants