additionals icon indicating copy to clipboard operation
additionals copied to clipboard

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

Open picman opened this issue 4 years ago • 5 comments

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 avatar May 10 '21 07:05 picman

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

picman avatar May 10 '21 08:05 picman

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

hermannkm avatar Jul 21 '21 13:07 hermannkm

Hi @picman,

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

alexandermeindl avatar Jul 14 '22 03:07 alexandermeindl

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?

picman avatar Jul 14 '22 07:07 picman

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.

alexandermeindl avatar Jul 14 '22 12:07 alexandermeindl