alphanodes / additionals

Redmine plugin for easy customization of settings, text and content display by using personal or role-based dashboards (drag&drop), providing wiki macros and act as library for other plugins.
https://www.redmine.org/plugins/additionals
GNU General Public License v2.0
131 stars 43 forks source link

Gemspec error due to 'spec.version = Additionals::VERSION' #102

Closed picman closed 1 year ago

picman commented 3 years ago

If I run a Ruby file in another Redmine plugin, I get the following error in Additionals;

ruby plugins/redmine_xapian/extra/xapian_indexer.rb
[!] There was an error parsing `Gemfile`: 
[!] There was an error parsing `Gemfile`: 
[!] There was an error while loading `additionals.gemspec`: uninitialized constant Additionals::VERSION. Bundler cannot continue.

 #  from /opt/redmine/plugins/additionals/additionals.gemspec:9
 #  -------------------------------------------
 #    spec.name          = 'additionals'
 >    spec.version       = Additionals::VERSION
 #    spec.authors       = ['AlphaNodes']
 #  -------------------------------------------
. Bundler cannot continue.

 #  from /opt/redmine/plugins/additionals/Gemfile:4
 #  -------------------------------------------
 #  # Specify your gem's dependencies in additionals.gemspec
 >  gemspec
 #  
 #  -------------------------------------------
. Bundler cannot continue.

 #  from /opt/redmine/Gemfile:108
 #  -------------------------------------------
 #  Dir.glob File.expand_path("../plugins/*/{Gemfile,PluginGemfile}", __FILE__) do |file|
 >    eval_gemfile file
 #  end
 #  -------------------------------------------
picman commented 3 years ago

A workaround is to modify lib/additionals/version.rb as follows:

# frozen_string_literal: true

module Additionals
-- VERSION = '3.0.3-master' unless defined? VERSION
++ VERSION = '3.0.3-master'
end
hermannkm commented 3 years ago

Me too having this problem. Many thanks for your workaround! Probably additionals plugin could be made more stable...

alexandermeindl commented 2 years ago

Hi @picman,

do you get this error with latest additionals, yet? I never had this problems you described with other plugins.

picman commented 2 years ago

With the master branch:

$ ruby plugins/redmine_xapian/extra/xapian_indexer.rb

[!] There was an error parsing `Gemfile`: 
[!] There was an error parsing `Gemfile`: 
[!] There was an error while loading `additionals.gemspec`: uninitialized constant Additionals::PluginVersion::VERSION. Bundler cannot continue.

The reason is unclear for me, but, can't you simple remove the check unless defined? VERSION. Why is it there?

alexandermeindl commented 2 years ago

Because this plugin can be installed as Gem. I did not find a solution for this without initializing VERSION constant twice. That is the reason. If I find a solution for that, I can remove this check.