{"record":{"id":"af9be5222d479ec3","repo":"ruby/rubygems","slug":"could-not-install-to-path-bundle-path-because","errorCode":null,"errorMessage":"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.","messagePattern":"Could not install to path `#(.+?)` because a file already exists at that path\\. Either remove or rename the file so the directory can be created\\.","errorType":"exception","errorClass":"PathError","httpStatus":null,"severity":"error","filePath":"lib/bundler.rb","lineNumber":110,"sourceCode":"      (defined?(@ui) && @ui) || (self.ui = UI::Shell.new)\n    end\n\n    def ui=(ui)\n      Bundler.rubygems.ui = UI::RGProxy.new(ui)\n      @ui = ui\n    end\n\n    # Returns absolute path of where gems are installed on the filesystem.\n    def bundle_path\n      @bundle_path ||= Pathname.new(configured_bundle_path.path).expand_path(root)\n    end\n\n    def create_bundle_path\n      mkdir_p(bundle_path) unless bundle_path.exist?\n\n      @bundle_path = bundle_path.realpath\n    rescue Errno::EEXIST\n      raise PathError, \"Could not install to path `#{bundle_path}` \" \\\n        \"because a file already exists at that path. Either remove or rename the file so the directory can be created.\"\n    end\n\n    def configured_bundle_path\n      @configured_bundle_path ||= Bundler.settings.path.tap(&:validate!)\n    end\n\n    # Returns absolute location of where binstubs are installed to.\n    def bin_path\n      @bin_path ||= begin\n        path = Bundler.settings[:bin] || \"bin\"\n        path = Pathname.new(path).expand_path(root).expand_path\n        mkdir_p(path)\n        path\n      end\n    end\n\n    # Turns on the Bundler runtime. After +Bundler.setup+ call, all +load+ or","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/bundler.rb#L92-L128","documentation":"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.","triggerScenarios":"Thrown at lib/bundler.rb:110 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}