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

Cannot install any extensions #11909

Open
nicknetender opened this issue Aug 1, 2023 · 9 comments
Open

Cannot install any extensions #11909

nicknetender opened this issue Aug 1, 2023 · 9 comments

Comments

@nicknetender
Copy link

Context

I am trying to install some extensions into a fresh Spree 4.6 installation. All extensions fail with an error.

Expected Behavior

Spree should run/boot/work/start with any extension installed according to the documentation, but it does not.

Actual Behavior

The application fails to boot at all.

Possible Fix

Update Spree documentation to clarify that either

  • extensions are not working at all, or
  • include instructions as to how to install them

Steps to Reproduce

  1. Set up a fresh installation as per https://dev-docs.spreecommerce.org/getting-started/installation
  2. run migrations, etc until the point where Spree is working
  3. Add any extension to the gem file according to the documentation
  4. application no longer boots

Your Environment

  • Version used:
  • Gemfile:
# Rails 7 gems, application works with the Gemfile until an(y) extension is added
gem 'spree', '~> 4.6'
gem 'spree_sample', '~> 4.6'
gem 'spree_emails', '~> 4.6'
gem 'spree_backend', '~> 4.6'
gem 'spree_gateway', '~> 3.10'
gem 'spree_auth_devise', '~> 4.5'
gem 'spree_i18n', '~> 5.1'
gem 'spree_dev_tools', require: false, group: %w[test development]

# extension added to Gemfile as per documentation, app no longer boots upon bundling this in:
gem 'spree_print_invoice', github: 'spree-contrib/spree_print_invoice', branch: 'master'

  • Any relevant stack traces ("Full trace" preferred):
/usr/local/rvm/gems/ruby-3.2.0/bundler/gems/spree_print_invoice-baf2e8797ea4/lib/spree_print_invoice/engine.rb:10:in `block in <class:Engine>': uninitialized constant Spree::PrintInvoiceSetting (NameError)

      Spree::PrintInvoice::Config = Spree::PrintInvoiceSetting.new
                                         ^^^^^^^^^^^^^^^^^^^^^
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:32:in `instance_exec'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:32:in `run'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:61:in `block in run_initializers'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:50:in `each'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:50:in `tsort_each_child'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:415:in `call'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:415:in `each_strongly_connected_component_from'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:347:in `each'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:347:in `call'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
	from /usr/local/rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/initializable.rb:60:in `run_initializers'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/application.rb:372:in `initialize!'
	from /app/app/src/config/environment.rb:5:in `<main>'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/zeitwerk-2.6.10/lib/zeitwerk/kernel.rb:38:in `require'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/application.rb:348:in `require_environment!'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/command/actions.rb:28:in `require_environment!'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/commands/generate/generate_command.rb:21:in `perform'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/command/base.rb:87:in `perform'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/command.rb:48:in `invoke'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/railties-7.0.6/lib/rails/commands.rb:18:in `<main>'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /usr/local/rvm/gems/ruby-3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from bin/rails:4:in `<main>'

I have tried installing all extensions, each and every one fail with a similar error saying it can't find some class/constant.

@rafalcymerys
Copy link
Member

Hi @nicknetender - this is due to the fact that Ruby 3 made some changes to how the autoloader works, and the extension hasn't been updated. The update itself is quite simple, here's a pattern that you can follow: spree-contrib/spree_braintree_vzero@fe07cd2
Feel free to submit a PR to the specific spree-contrib repository, we'll be happy to merge it

@nicknetender
Copy link
Author

Hi @nicknetender - this is due to the fact that Ruby 3 made some changes to how the autoloader works, and the extension hasn't been updated. The update itself is quite simple, here's a pattern that you can follow: spree-contrib/spree_braintree_vzero@fe07cd2
Feel free to submit a PR to the specific spree-contrib repository, we'll be happy to merge it

Thank you sir.

I've been playing with some of the extensions, it seems some/most of them (after making the suggested change) fail with:
NameError: uninitialized constant Spree::AppConfiguration

Did a grep through the Spree source and couldn't find any class by that name. Our friend Google says it does show up in the Solidus codebase though. 🤔

Do you have any idea whether these modules ever worked, or were designed to work with Spree? I think what's happening is really strange. I was really hoping this would be nice and smooth 💔

@rafalcymerys
Copy link
Member

Hi @nicknetender could you send a link to the exact extension?

@nicknetender
Copy link
Author

Hi @nicknetender could you send a link to the exact extension?

Most if not of them fail with either the error mentioned above, or are outdated (require core < 3.something or 4.0) and if updating the dependency version (and hoping to resolve any issues upon load & test) they eventually fail with the same error.

Here are a bunch of extensions we've tried, please excuse me for dumping this code brick. Some are linked directly from the Extensions section on the website.

# https://github.com/spree-contrib/spree_globalize
# gem 'spree_globalize', github: 'spree-contrib/spree_globalize'
# TODO fails on boot, fix it

# TODO run a rails g spree_globalize:install

# https://github.com/spree-contrib/spree_handling_fees
# gem 'spree_handling_fees', github: 'spree-contrib/spree_handling_fees'
# TODO outdated, fix it: fork and upgrade the gem
# TODO run a bundle exec rails g spree_handling_fees:install

# https://github.com/spree-contrib/spree_comments
# gem "spree_comments", github: 'spree-contrib/spree_comments'
# TODO outdated, fix it: fork and upgrade the gem
# TODO run a bundle exec rails g spree_comments:install

# https://github.com/spree-contrib/spree_print_invoice
# gem 'spree_print_invoice', github: 'spree-contrib/spree_print_invoice', branch: 'master'
# TODO run a bundle exec rails g spree_print_invoice:install

# https://github.com/TruemarkDev/spree-html-invoice
# gem 'spree_html_invoice', git: 'https://github.com/vinsol-spree-contrib/spree-html-invoice', branch: 'master'
# TODO outdated, fix it: fork and upgrade the gem

# https://github.com/spree-contrib/spree_analytics_trackers
# gem 'spree_analytics_trackers', '~> 2.0'
# TODO run a bundle exec rails g spree_analytics_trackers:install

# https://github.com/spree-contrib/spree_affiliate
# gem 'spree_affiliate'
# TODO outdated, fix it: fork and upgrade the gem
# TODO run a bundle exec rails g spree_affiliate:install

# https://github.com/spree-contrib/spree_mailchimp_ecommerce
# gem 'spree_mailchimp_ecommerce', github: 'spree-contrib/spree_mailchimp_ecommerce', branch: 'master'
# TODO run a $ bundle exec rails g spree_mailchimp_ecommerce:install

# https://github.com/MatthewKennedy/spree_product_feed
# gem 'spree_product_feed', github: 'matthewkennedy/spree_product_feed'
# TODO run a bundle exec rails g spree_product_feed:install

# https://github.com/spree-contrib/spree_sitemap
# gem 'spree_sitemap', github: 'spree-contrib/spree_sitemap'
# TODO bundle exec rails g spree_sitemap:install

# https://github.com/ShopFelixGray/spree_virtual_gift_card
# gem 'spree_virtual_gift_card', github: 'ShopFelixGray/spree_virtual_gift_card', branch: 'master' #'X-X-stable'
# TODO need to fork their repo into netenders org and upgrade it to work with current spree version
# TODO run a bundle exec rails g spree_virtual_gift_card:install

# https://github.com/spree-contrib/spree_multi_vendor
# gem 'spree_multi_vendor'
# TODO run a bundle exec rails g spree_multi_vendor:install
# bundle exec rake spree_multi_vendor:sample:create

# https://github.com/ShopFelixGray/spree_pay_with_amazon
# gem 'spree_amazon_payments', github: 'boomerdigital/spree_pay_with_amazon'
# TODO run a bundle exec rails g spree_amazon_payments:install

# https://github.com/spree-contrib/spree_braintree_vzero
# gem 'spree_braintree_vzero', '~> 3.5'
# TODO run a bundle exec rails g spree_braintree_vzero:install

# https://github.com/mollie/spree-mollie-gateway
# gem 'spree_mollie_gateway'
# TODO run a bundle exec rails g spree_mollie_gateway:install

# https://github.com/spree-contrib/better_spree_paypal_express
# gem 'spree_paypal_express', github: 'spree-contrib/better_spree_paypal_express'
# TODO run a bundle exec rails g spree_paypal_express:install

# https://github.com/spree-contrib/spree_digital
# gem 'spree_digital', github: 'spree-contrib/spree_digital'
# TODO run a bundle exec rails g spree_digital:install

# TODO add https://github.com/spree-contrib/spree_videos

# https://github.com/spree-contrib/spree_volume_pricing
# gem 'spree_volume_pricing', github: 'spree-contrib/spree_volume_pricing'
# gem "spree_volume_pricing", github: "nicknetender/spree_volume_pricing"
# TODO fails with some error, fix it
# TODO run a rails generate spree_volume_pricing:install

# https://github.com/TruemarkDev/spree_products_qa
# gem 'spree_products_qa', git: 'https://github.com/TruemarkDev/spree_products_qa.git', branch: 'master'
# TODO run a bundle exec rails g spree_products_qa:install

# TODO add https://github.com/spree-contrib/spree_searchkick

# https://github.com/spree-contrib/spree_active_shipping
# gem 'spree_active_shipping', github: 'spree-contrib/spree_active_shipping'
# TODO check out this issue https://github.com/spree-contrib/spree_active_shipping/issues/289
# TODO fork the repo, upgrade to 4.*
# TODO run a bundle exec rake railties:install:migrations

# https://github.com/ShopFelixGray/spree_easypost
# gem 'spree_easypost', github: 'ShopFelixGray/spree_easypost'
# TODO outdated, fix it
# TODO run a bundle exec rails g spree_easypost:install && rake db:migrate

# https://github.com/MatthewKennedy/spree_shipstation
# gem "spree_shipstation", github: "matthewkennedy/spree_shipstation"
# TODO run a bundle exec rails generate spree_shipstation:install

# https://github.com/spree-contrib/spree_social
# gem 'spree_social', github: 'spree-contrib/spree_social'
# TODO errors out, fix it
# TODO run a bundle exec rails g spree_social:install

# https://github.com/spree-contrib/spree_taxjar
# gem 'spree_taxjar', github: 'spree-contrib/spree_taxjar'
# TODO fails with error, fix it
# TODO run a bundle exec rails g spree_taxjar:install

# https://github.com/spree-contrib/spree-product-assembly
# gem 'spree_product_assembly', github: 'spree-contrib/spree-product-assembly'
# TODO run a bundle exec rails g spree_product_assembly:install

# https://github.com/spree-contrib/spree_related_products
# gem 'spree_related_products', github: 'spree-contrib/spree_related_products'
# TODO run a bundle exec rails g spree_related_products:install

@rafalcymerys
Copy link
Member

@nicknetender if you could point me to a specific one with this problem, I'll be happy to help :) I've just tried updating https://github.com/spree-contrib/spree_print_invoice/compare/chore/update_rails_7?expand=1 and it boots fine with just this change

@bpqr
Copy link

bpqr commented Mar 29, 2024

@rafalcymerys Sorry to bump this older comment. I'm working on spree_reviews to Rails 7.1 and getting this error when pushing to Heroku:

Zeitwerk::NameError: expected file /tmp/build_209785a3/vendor/bundle/ruby/3.3.0/bundler/gems/spree_reviews-0bbcaa96f2ac/app/overrides/add_reviews_after_product_properties.rb to define constant AddReviewsAfterProductProperties, but didn't (Zeitwerk::NameError)

I'm fairly new to Rails, coming from a PHP background, so trying to get up-to-speed on the workings and this is one that I'm not quite there with yet.

@rafalcymerys
Copy link
Member

Hi @bpqr - this is caused by recent changes in Rails autoloader - it now expects that every .rb file will define a constant with a related name. Deface overrides unfortunately don't follow that structure.
A potential solution would be to change the override in that file from .rb to a .deface file using Deface's DSL: https://github.com/spree/deface#using-the-deface-dsl-deface-files

@bpqr
Copy link

bpqr commented Mar 29, 2024

@rafalcymerys Thank you! All working now!

@stap780
Copy link

stap780 commented Apr 25, 2024

Hello @bpqr

in my project. before deploy i check zeitwerk until all will be good - bin/rails zeitwerk:check

and every error i write to initializer file - config/initializers/zietwerk.rb
for example add it like - AddReviewsAfterProductProperties = Class.new
zietwerk rb — rails_projects 2024-04-25 16-08-17
check screen file

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

4 participants