ruby/rubygems · error · PathError

Could not install to path `#{bundle_path}` because a file al

Error message

Could not install to path `#{bundle_path}` because a file already exists at that path. Either remove or rename the file so the directory can be created.

What it means

Error "Could not install to path `#{bundle_path}` because a file already exists at that path. Either remove or rename the file so the directory can be created." thrown in ruby/rubygems.

Source

Thrown at lib/bundler.rb:110

      (defined?(@ui) && @ui) || (self.ui = UI::Shell.new)
    end

    def ui=(ui)
      Bundler.rubygems.ui = UI::RGProxy.new(ui)
      @ui = ui
    end

    # Returns absolute path of where gems are installed on the filesystem.
    def bundle_path
      @bundle_path ||= Pathname.new(configured_bundle_path.path).expand_path(root)
    end

    def create_bundle_path
      mkdir_p(bundle_path) unless bundle_path.exist?

      @bundle_path = bundle_path.realpath
    rescue Errno::EEXIST
      raise PathError, "Could not install to path `#{bundle_path}` " \
        "because a file already exists at that path. Either remove or rename the file so the directory can be created."
    end

    def configured_bundle_path
      @configured_bundle_path ||= Bundler.settings.path.tap(&:validate!)
    end

    # Returns absolute location of where binstubs are installed to.
    def bin_path
      @bin_path ||= begin
        path = Bundler.settings[:bin] || "bin"
        path = Pathname.new(path).expand_path(root).expand_path
        mkdir_p(path)
        path
      end
    end

    # Turns on the Bundler runtime. After +Bundler.setup+ call, all +load+ or

View on GitHub (pinned to 86cbb817a3)

When it happens

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