-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Curious error with 'bundler/inline': Failed loading plugin `standard-custom' because we couldn't determine (RuntimeError) the corresponding plugin class to instantiate. #591
Comments
Okay, I'll be honest, this one sucks. First, I was able to reproduce this repeatedly by uninstalling standard-custom before each run (and nuking the local bundle folder): #!/usr/bin/env ruby
system "gem uninstall --ignore-dependencies --force standard-custom"
require 'bundler/inline'
gemfile(true) do
source "https://rubygems.org"
gem 'standard', path: '../standard'
end
load Gem.bin_path("standard", "standardrb") Given that the class raising this error also does some clever stuff when requiring each plugin, I expected that this line would be the culprit, which in this situation resolves to The issue appears to be at the line raising the error: Kernel.const_get(Gem.loaded_specs[plugin_name].metadata["default_lint_roller_plugin"]) Where Gem::Specification.new do |s|
s.name = "standard-custom"
s.version = Gem::Version.new("1.0.2")
s.installed_by_version = Gem::Version.new("0")
s.bindir = "exe"
s.date = Time.utc(2023, 11, 20)
s.dependencies = [Gem::Dependency.new("lint_roller", Gem::Requirement.new(["~> 1.0"]), :runtime), Gem::Dependency.new("rubocop", Gem::Requirement.new(["~> 1.50"]), :runtime)]
s.require_paths = ["lib"]
s.required_ruby_version = Gem::Requirement.new([">= 2.6.0"])
s.rubygems_version = "3.4.17"
s.specification_version = 4
s.summary = nil
end Compare that to an installed plugin like #<Bundler::StubSpecification:0x000000010fc548a0
@_remote_specification=
Gem::Specification.new do |s|
s.name = "standard-performance"
s.version = Gem::Version.new("1.2.1")
s.installed_by_version = Gem::Version.new("3.4.17")
s.authors = ["Justin Searls"]
s.bindir = "exe"
s.date = Time.utc(2023, 10, 10)
s.dependencies = [Gem::Dependency.new("lint_roller", Gem::Requirement.new(["~> 1.1"]), :runtime), Gem::Dependency.new("rubocop-performance", Gem::Requirement.new(["~> 1.19.1"]), :runtime)]
s.email = ["[email protected]"]
s.homepage = "https://github.com/standardrb/standard-performance"
s.licenses = ["MIT"]
s.metadata = {"changelog_uri"=>"https://github.com/standardrb/standard-performance/blob/main/CHANGELOG.md",
"default_lint_roller_plugin"=>"Standard::Performance::Plugin",
"homepage_uri"=>"https://github.com/standardrb/standard-performance",
"source_code_uri"=>"https://github.com/standardrb/standard-performance"}
s.require_paths = ["lib"]
s.required_ruby_version = Gem::Requirement.new([">= 2.7.0"])
s.rubygems_version = "3.4.17"
s.specification_version = 4
s.summary = "Standard Ruby Plugin providing configuration for rubocop-performance"
end,
@dependencies=[Gem::Dependency.new("lint_roller", Gem::Requirement.new(["~> 1.1"]), :runtime), Gem::Dependency.new("rubocop-performance", Gem::Requirement.new(["~> 1.19.1"]), :runtime)],
@full_name="standard-performance-1.2.1",
@name="standard-performance",
@original_platform="ruby",
@platform="ruby",
@required_ruby_version=Gem::Requirement.new([">= 2.7.0"]),
@required_rubygems_version=Gem::Requirement.new([">= 0"]),
@source=#<Bundler::Source::Rubygems:0x234620 rubygems repository https://rubygems.org/ or installed locally>,
@spec_fetcher=nil,
@stub=
#<Gem::StubSpecification:0x00000001046130c8
@activated=true,
@base_dir="/Users/justin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0",
@data=#<Gem::StubSpecification::StubLine:0x0000000104654208 @extensions=[], @full_name="standard-performance-1.2.1", @name="standard-performance", @platform="ruby", @require_paths=["lib"], @version=Gem::Version.new("1.2.1")>,
@default_gem=false,
@extension_dir=nil,
@full_gem_path="/Users/justin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/standard-performance-1.2.1",
@full_require_paths=["/Users/justin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/standard-performance-1.2.1/lib"],
@gem_dir=nil,
@gems_dir="/Users/justin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems",
@ignored=nil,
@loaded_from="/Users/justin/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/specifications/standard-performance-1.2.1.gemspec",
@name=nil,
@spec=
Gem::Specification.new do |s|
s.name = "standard-performance"
s.version = Gem::Version.new("1.2.1")
s.installed_by_version = Gem::Version.new("3.4.17")
s.authors = ["Justin Searls"]
s.bindir = "exe"
s.date = Time.utc(2023, 10, 10)
s.dependencies = [Gem::Dependency.new("lint_roller", Gem::Requirement.new(["~> 1.1"]), :runtime), Gem::Dependency.new("rubocop-performance", Gem::Requirement.new(["~> 1.19.1"]), :runtime)]
s.email = ["[email protected]"]
s.homepage = "https://github.com/standardrb/standard-performance"
s.licenses = ["MIT"]
s.metadata = {"changelog_uri"=>"https://github.com/standardrb/standard-performance/blob/main/CHANGELOG.md",
"default_lint_roller_plugin"=>"Standard::Performance::Plugin",
"homepage_uri"=>"https://github.com/standardrb/standard-performance",
"source_code_uri"=>"https://github.com/standardrb/standard-performance"}
s.require_paths = ["lib"]
s.required_ruby_version = Gem::Requirement.new([">= 2.7.0"])
s.rubygems_version = "3.4.17"
s.specification_version = 4
s.summary = "Standard Ruby Plugin providing configuration for rubocop-performance"
end>,
@version=Gem::Version.new("1.2.1")> Because lint_roller depends on
The fact that the From the perspective of me as a gem author relying on spec.metadata, this seems to be a bug in Bundler (or maybe rubygems, depending on whether Bundler is just wrapping an incomplete spec from an underlying gems API), since I can't find any documentation stating that it's not safe to rely on the metadata API after the gem is loaded and required. I think that should be our next step. Paging @deivid-rodriguez and @hsbt in case they might be able to offer advice here |
I'm trying to create a self-contained script to run
standard
usingbundler/inline
like this:Whenever I call this script and
standard-custom
is not already installed, it raises the strange error from this issue's title. If I re-run the script it works as expected. If I removestandard-custom
from./.bundle
and re-run the script, the error occurs again.If I use a standalone
Gemfile
, the error does not occur, even if installing gems and running the code happens in one process.Details:
This is on MacOS 14.1. ("Sonoma"), in case that matters.
I'd love to spare myself a
Gemfile
, so I'd be happy for any ideas or fixes.If I can help with further information, please let me know.
The text was updated successfully, but these errors were encountered: