maxrossello / redmine_better_overview

Provides a better redmine project overview with details about subprojects
MIT License
11 stars 8 forks source link

NoMethodError: undefined method `underscore' for nil:NilClass (NoMethodError) #4

Closed Froskur closed 2 months ago

Froskur commented 2 months ago

Hi! I did try use plugin in my redmine, but I have this error if I will run command "bundle install".

Bundle complete! 58 Gemfile dependencies, 104 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
rake aborted!
NoMethodError: undefined method `underscore' for nil:NilClass (NoMethodError)

      args[:name] = "#{current_railtie.underscore}_#{args[:name]}" if Rails.application.try(:config).try(:deface).try(:namespaced) || args.delete(:namespaced)
                                      ^^^^^^^^^^^
/var/www/redmine/config/environment.rb:16:in `<top (required)>'
<internal:/usr/local/rbenv/versions/3.2.4/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/usr/local/rbenv/versions/3.2.4/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/var/www/redmine/lib/tasks/redmine.rake:73:in `block (2 levels) in <top (required)>'
/usr/local/rbenv/versions/3.2.4/bin/bundle:25:in `load'
/usr/local/rbenv/versions/3.2.4/bin/bundle:25:in `<main>'
Tasks: TOP => redmine:plugins:migrate => environment
(See full trace by running task with --trace)

Maybe this information will help you :)

My Environment:

  Redmine version                5.1.2.stable
  Ruby version                   3.2.4-p170 (2024-04-23) [x86_64-linux]
  Rails version                  6.1.7.7
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
maxrossello commented 2 months ago

is the offending line in your config/environment.rb at line 16?

That seems not to be something coming from the official Redmine, and the problem seems having nothing to do with this plugin either

Froskur commented 2 months ago

Hmmm... I don't change this file, it is normal...

# frozen_string_literal: true

# Load the Rails application
require File.expand_path('../application', __FILE__)

# Make sure there's no plugin in vendor/plugin before starting
vendor_plugins_dir = File.join(Rails.root, "vendor", "plugins")
if Dir.glob(File.join(vendor_plugins_dir, "*")).any?
  $stderr.puts "Plugins in vendor/plugins (#{vendor_plugins_dir}) are no longer allowed. " \
    "Please, put your Redmine plugins in the `plugins` directory at the root of your " \
    "Redmine directory (#{File.join(Rails.root, "plugins")})"
  exit 1
end

# Initialize the Rails application
Rails.application.initialize!

I don't see problem, but I don't very well rub. I use TURNKEY redmine build. Ok, I try use trace for search place with this problem

maxrossello commented 2 months ago

current_railtie is the variable that happens to be nil.

I found the offending code at line 43 here: https://github.com/spree/deface/blob/master/lib/deface/override.rb. This seems a deface harness different from the required redmine_base_deface.

Would you mind trying to install deface from https://github.com/maxrossello/redmine_base_deface, last version being 5.1.1 (I keep it in sync with minimum compatible redmine version) or otherwise also https://github.com/jbbarth/redmine_base_deface?

I suspect a conflict in the 'deface' concept adopted by different plugins.

Also, I don't understand how the "Tasks: TOP => redmine:plugins:migrate => environment" output gets generated by bundle install

Froskur commented 2 months ago

image

And this if do you need:

root@portal2 ~#
root@portal2 ~#
root@portal2 ~#
root@portal2 ~# cd /var/www/redmine/
root@portal2 .../www/redmine#
root@portal2 .../www/redmine# bundle install
Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users on this machine.
Bundle complete! 58 Gemfile dependencies, 104 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
root@portal2 .../www/redmine# git clone https://github.com/maxrossello/redmine_base_deface.git plugins/redmine_base_deface
Cloning into 'plugins/redmine_base_deface'...
remote: Enumerating objects: 162, done.
remote: Counting objects: 100% (48/48), done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 162 (delta 33), reused 35 (delta 27), pack-reused 114 (from 1)
Receiving objects: 100% (162/162), 24.90 KiB | 606.00 KiB/s, done.
Resolving deltas: 100% (67/67), done.
root@portal2 .../www/redmine# bundle install
Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Could not find compatible versions

Because redmine_plugin_kit >= 1.0.2, < 1.0.3 depends on deface = 1.8.2
  and redmine_plugin_kit < 1.0.2 depends on deface = 1.8.1,
  redmine_plugin_kit < 1.0.3 requires deface = 1.8.1 OR = 1.8.2.
So, because redmine_plugin_kit >= 1.0.3 depends on deface = 1.9.0
  and Gemfile depends on deface = 1.6.2,
  version solving has failed.
root@portal2 .../www/redmine#
maxrossello commented 2 months ago

Ok now the problem is that you have other plugins requiring specific versions of deface. Intended deface repository is https://github.com/jbbarth/redmine_base_deface but some former revision had a regression with the DSL that redmine_better_overview needs which I contributed to fix.

Deface plugin is generally backward compatible, so a strict requirement for an earlier version is overkill. You may therefore fix your environment in different ways:

  1. remove redmine_plugin_kit plugin
  2. fake the redmine_plugin_kit required deface version to 5.1.1
  3. fake the deface plugin's init.rb to pretend to be version 1.9.0 or whatever works for you

Note that the compatibility of Redmine plugins is a common issue, also because the Redmine automated tests fail when a plugin changes its default behavior. For this reason I can only support a limited set which I test all together with an extended test set that encompasses the possible deviations introduced by plugins: have a look at https://github.com/maxrossello/redmine_testsuites