ruby/rubygems · error · PluginGemfileError

Undefined local variable or method `#{name}' for Gemfile

Error message

Undefined local variable or method `#{name}' for Gemfile

What it means

Error "Undefined local variable or method `#{name}' for Gemfile" thrown in ruby/rubygems.

Source

Thrown at lib/bundler/plugin/dsl.rb:34

      #
      # When we encounter :type attribute with a source block, we add a plugin
      # by name bundler-source-<type> to list of plugins to be installed.
      #
      # These plugins are optional and are not installed when there is conflict
      # with any other plugin.
      attr_reader :inferred_plugins

      def initialize
        super
        @inferred_plugins = [] # The source plugins inferred from :type
      end

      def gem(*args)
        # Ignore regular dependencies when doing the plugins-only pre-parse
      end

      def method_missing(name, *args)
        raise PluginGemfileError, "Undefined local variable or method `#{name}' for Gemfile" unless Bundler::Dsl.method_defined? name
      end

      def source(source, *args, &blk)
        options = args.last.is_a?(Hash) ? args.pop.dup : {}
        options = normalize_hash(options)
        return super unless options.key?("type")

        plugin_name = "bundler-source-#{options["type"]}"

        return if @dependencies.any? {|d| d.name == plugin_name }

        plugin(plugin_name)
        @inferred_plugins << plugin_name
      end
    end
  end
end

View on GitHub (pinned to 86cbb817a3)

When it happens

Trigger: Thrown at lib/bundler/plugin/dsl.rb:34 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23). Data as JSON: /api/errors/9594b508be9fd0d2. Report an issue: GitHub.