Loading activejob and sidekiq RBS in one environment raises RBS::DuplicatedDeclarationError for ::Sidekiq::Worker. The failure happens in RBS::Environment while rbs validate loads signatures.
#1068 added this alias:
activejob already has a stub for the same name:
|
# Remove the fake type if the real type is available |
|
module Sidekiq |
|
module Worker |
|
end |
|
end |
The generated ActiveJob RBS uses that name:
|
class JobWrapper |
|
# nodoc: |
|
include Sidekiq::Worker |
RBS does not allow a module declaration and a module alias with the same name.
Checked with rbs 4.2.0, against 1b9862295fe32611a96ff5668408cdacd6876170 (main HEAD at the time of writing).
Repro
From a checkout of this repository. Each gem loads. Loading both fails at environment construction.
rbs --no-collection -I .gem_rbs_collection/activejob/6.0 -I .gem_rbs_collection/sidekiq/7.0 validate
/Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:361:in 'RBS::Environment#insert_rbs_decl': .gem_rbs_collection/activejob/6.0/patch.rbs:15:2...16:5: Duplicated declaration: ::Sidekiq::Worker (RBS::DuplicatedDeclarationError)
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:311:in 'block in RBS::Environment#insert_rbs_decl'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/ast/declarations.rb:26:in 'block in RBS::AST::Declarations::NestedDeclarationHelper#each_decl'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/ast/declarations.rb:24:in 'Array#each'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/ast/declarations.rb:24:in 'RBS::AST::Declarations::NestedDeclarationHelper#each_decl'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:310:in 'RBS::Environment#insert_rbs_decl'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:461:in 'block in RBS::Environment#add_source'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:460:in 'Array#each'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:460:in 'RBS::Environment#add_source'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment_loader.rb:119:in 'block in RBS::EnvironmentLoader#load'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment_loader.rb:162:in 'block (2 levels) in RBS::EnvironmentLoader#each_signature'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/file_finder.rb:24:in 'Array#each'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/file_finder.rb:24:in 'RBS::FileFinder.each_file'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment_loader.rb:154:in 'block in RBS::EnvironmentLoader#each_signature'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment_loader.rb:144:in 'block in RBS::EnvironmentLoader#each_dir'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment_loader.rb:143:in 'Array#each'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment_loader.rb:143:in 'RBS::EnvironmentLoader#each_dir'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment_loader.rb:151:in 'RBS::EnvironmentLoader#each_signature'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment_loader.rb:115:in 'RBS::EnvironmentLoader#load'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:71:in 'block in RBS::Environment.from_loader'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:70:in 'Kernel#tap'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/environment.rb:70:in 'RBS::Environment.from_loader'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/cli/validate.rb:50:in 'RBS::CLI::Validate#initialize'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/cli.rb:458:in 'RBS::CLI#run_validate'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/lib/rbs/cli.rb:141:in 'RBS::CLI#run'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/gems/4.0.0/gems/rbs-4.2.0/exe/rbs:7:in '<top (required)>'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/4.0.0/rubygems.rb:305:in 'Kernel#load'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/lib/ruby/4.0.0/rubygems.rb:305:in 'Gem.activate_and_load_bin_path'
from /Users/nhosoya/.local/share/mise/installs/ruby/4.0.6/bin/rbs:25:in '<main>'
Same error from rbs validate when a lockfile installs both gems (Rails app using Sidekiq).
Loading
activejobandsidekiqRBS in one environment raisesRBS::DuplicatedDeclarationErrorfor::Sidekiq::Worker. The failure happens inRBS::Environmentwhilerbs validateloads signatures.#1068 added this alias:
gem_rbs_collection/gems/sidekiq/7.0/job.rbs
Line 82 in 1b98622
activejobalready has a stub for the same name:gem_rbs_collection/gems/activejob/6.0/patch.rbs
Lines 13 to 17 in 1b98622
The generated ActiveJob RBS uses that name:
gem_rbs_collection/gems/activejob/6.0/activejob-generated.rbs
Lines 953 to 955 in 1b98622
RBS does not allow a module declaration and a module alias with the same name.
Checked with rbs 4.2.0, against
1b9862295fe32611a96ff5668408cdacd6876170(mainHEAD at the time of writing).Repro
From a checkout of this repository. Each gem loads. Loading both fails at environment construction.
Same error from
rbs validatewhen a lockfile installs both gems (Rails app using Sidekiq).