ruby/rubygems · error · GemfileNotFound

Could not locate Gemfile or .bundle/ directory

Error message

Could not locate Gemfile or .bundle/ directory

What it means

Error "Could not locate Gemfile or .bundle/ directory" thrown in ruby/rubygems.

Source

Thrown at lib/bundler.rb:323

    def home
      bundle_path.join("bundler")
    end

    def install_path
      home.join("gems")
    end

    def specs_path
      bundle_path.join("specifications")
    end

    def root
      @root ||= begin
                  SharedHelpers.root
                rescue GemfileNotFound
                  bundle_dir = default_bundle_dir
                  raise GemfileNotFound, "Could not locate Gemfile or .bundle/ directory" unless bundle_dir
                  Pathname.new(File.expand_path("..", bundle_dir))
                end
    end

    def app_config_path
      if app_config = ENV["BUNDLE_APP_CONFIG"]
        app_config_pathname = Pathname.new(app_config)

        if app_config_pathname.absolute?
          app_config_pathname
        else
          app_config_pathname.expand_path(root)
        end
      else
        root.join(".bundle")
      end
    end

View on GitHub (pinned to 86cbb817a3)

When it happens

Trigger: Thrown at lib/bundler.rb:323 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/5c305266bc5dfdc4. Report an issue: GitHub.