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

Error start the application after gems alphabetically sorted #8207

Closed
EnziinSystem opened this issue Jun 24, 2020 · 5 comments
Closed

Error start the application after gems alphabetically sorted #8207

EnziinSystem opened this issue Jun 24, 2020 · 5 comments

Comments

@EnziinSystem
Copy link

My environment:

bash-5.0# rubocop -V
0.80.1 (using Parser 2.7.1.4, running on ruby 2.7.1 x86_64-linux-musl)
bash-5.0# ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux-musl]
bash-5.0# rails -v
Rails 6.0.3.2

In the Gemfile:

gem 'activeadmin', '~> 2.7'
gem 'active_admin-sortable_tree', '~> 2.1'

I start the Puma server, my application working normally.
Now, I sort gems by alphabetically and Gemfile become:

gem 'active_admin-sortable_tree', '~> 2.1'
gem 'activeadmin', '~> 2.7'

I start the Puma, oops, it' error because gem 'active_admin-sortable_tree' need gem 'activeadmin' loaded.

In general, gem B depends on Gem A. If the order loaded change by RuboCop then it raises an error.

We can not be known anything about the order load gems depends on themself in an application.

The next version of Rubocop, please remove the method sort Gems by A-Z as below.

https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Bundler/OrderedGems

Puma starting in single mode...
* Version 4.3.5 (ruby 2.7.1-p83), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
! Unable to load application: NameError: uninitialized constant ActiveAdmin
bundler: failed to load command: puma (/usr/local/bundle/bin/puma)
NameError: uninitialized constant ActiveAdmin
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:80:in `block in load_missing_constant'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:9:in `without_bootsnap_cache'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:80:in `rescue in load_missing_constant'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `load_missing_constant'
  /usr/local/bundle/gems/active_admin-sortable_tree-2.1.0/lib/active_admin/sortable_tree/compatibility.rb:1:in `<main>'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
  /usr/local/bundle/gems/active_admin-sortable_tree-2.1.0/lib/active_admin/sortable_tree.rb:1:in `<main>'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
  /usr/local/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
  /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:88:in `rescue in block in require'
  /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:65:in `block in require'
  /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
  /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
  /usr/local/lib/ruby/2.7.0/bundler.rb:174:in `require'
  /home/config/application.rb:8:in `<top (required)>'
@marcandre
Copy link
Contributor

marcandre commented Jun 24, 2020

In general, gem B depends on Gem A

Yes, but that is stated in each gem's manifest. gem B is responsible for requiring gem A.

I'd file a bug with active_admin-sortable_tree: they should be doing the require 'active_admin'

@EnziinSystem
Copy link
Author

In general, gem B depends on Gem A

Yes, but that is stated in each gem's manifest. gem B is responsible for requiring gem A.

I'd file a bug with active_admin-sortable_tree: they should be doing the require 'active_admin'

I known require it, but a program don't raise an error because sorted gems A-Z only.
When we use RuboCop, our code more than beautiful, but not have any errors.

@marcandre
Copy link
Contributor

I did it for you

We should consider sorting after removing all the - and _ though. Creating #8209

@EnziinSystem
Copy link
Author

I did it for you

We should consider sorting after removing all the - and _ though. Creating #8209

Thank you!

marcandre added a commit to marcandre/rubocop that referenced this issue Jun 30, 2020
@marcandre
Copy link
Contributor

Future versions will sort ignoring - and _ so this should also resolve this for you. Thanks for raising this issue 😄

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

2 participants