ForestAdmin / forest-rails

💎 Ruby on Rails agent for Forest Admin to integrate directly to your existing Ruby on Rails backend application.
https://www.forestadmin.com
GNU General Public License v3.0
374 stars 77 forks source link

Conflicting class name with `jsonapi-serializer` gem #448

Open gusverdywid opened 3 years ago

gusverdywid commented 3 years ago

Expected behavior

It plays well with any json serializer library. Mine is https://github.com/jsonapi-serializer/jsonapi-serializer

Actual behavior

It does not play well with jsonapi-serializer.

Failure Logs

TypeError:
  superclass mismatch for class Error
# ~/.gem/ruby/3.0.0/gems/jsonapi-serializer-2.2.0/lib/jsonapi/serializer/errors.rb:5:in `<module:Serializer>'
# ~/.gem/ruby/3.0.0/gems/jsonapi-serializer-2.2.0/lib/jsonapi/serializer/errors.rb:4:in `<module:JSONAPI>'
# ~/.gem/ruby/3.0.0/gems/jsonapi-serializer-2.2.0/lib/jsonapi/serializer/errors.rb:3:in `<top (required)>'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
# ~/.gem/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `block in require'
# ~/.gem/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:299:in `load_dependency'
# ~/.gem/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `require'
# ~/.gem/ruby/3.0.0/gems/jsonapi-serializer-2.2.0/lib/fast_jsonapi.rb:3:in `<top (required)>'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
# ~/.gem/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `block in require'
# ~/.gem/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:299:in `load_dependency'
# ~/.gem/ruby/3.0.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `require'
# ~/.gem/ruby/3.0.0/gems/jsonapi-serializer-2.2.0/lib/jsonapi/serializer.rb:1:in `<top (required)>'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
# ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
# ./config/application.rb:22:in `<top (required)>'
# ./config/environment.rb:4:in `require_relative'
# ./config/environment.rb:4:in `<top (required)>'
# ./spec/rails_helper.rb:33:in `require'
# ./spec/rails_helper.rb:33:in `<top (required)>'
# ------------------
# --- Caused by: ---
# LoadError:
#   cannot load such file -- jsonapi-serializer
#   ~/.gem/ruby/3.0.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:34:in `require'

Context

It is a fresh install of rails and I use jsonapi-serializer (https://github.com/jsonapi-serializer/jsonapi-serializer) which was originally by Netflix. After having a look deeper, I found out that one of the gem used by forest_liana (jsonapi-serializers / https://github.com/fotinakis/jsonapi-serializers) has a conflicting code with the code by jsonapi-serializer (without the S at the end). It seems the jsonapi-serializers does not the same module name as its library name hence the conflict. See below.

The Error module by the jsonapi-serializer

Screen Shot 2021-04-15 at 11 16 19 am

The Error module by the jsonapi-seraliazers

Screen Shot 2021-04-15 at 11 25 44 am

The jsonapi-serializers should have used a the same name with their library name or at least prefixed the module name

arnaudbesnier commented 3 years ago

Hi @verdywid, Thanks for the report. The team is currently trying to fix this specific painful conflict.

For your information, we have a similar topic opened in our Community forum: https://community.forestadmin.com/t/error-just-after-installing-forest/1801/13

sruchi123 commented 3 years ago

HI , can you fix this issue asap if possible.. i am also getting same issue.

arnaudbesnier commented 3 years ago

Hi @sruchi123, As explained in my previous message, our team is currently investigating and trying to patch the package to prevent this issue in the future.