ruby/ruby · error · Bundler::PathError

13

13

Error message

Your bundle path contains text matching #{path_separator.inspect}, which is the path separator for your system. Bundler cannot function correctly when the Bundle path contains the system's PATH separator. Please change your bundle path to not match #{path_separator.inspect}.
Your current bundle path is '#{Bundler.bundle_path}'.

What it means

SharedHelpers#validate_bundle_path guards the configured bundle path: if Bundler.bundle_path.to_s splits on Gem.path_separator (the OS list separator, e.g. ':' on Unix, ';' on Windows) into more than one segment, Bundler::PathError is raised. A bundle path containing the separator would be ambiguous everywhere Bundler and RubyGems split path lists, so Bundler refuses to operate and echoes the current path.

Source

Thrown at lib/bundler/shared_helpers.rb:246

    def relative_path_to(destination, from: pwd)
      Pathname.new(destination).relative_path_from(from).to_s
    rescue ArgumentError
      # on Windows, if source and destination are on different drivers, there's no relative path from one to the other
      destination
    end

    private

    def validate_bundle_path
      path_separator = Bundler.rubygems.path_separator
      return unless Bundler.bundle_path.to_s.split(path_separator).size > 1
      message = "Your bundle path contains text matching #{path_separator.inspect}, " \
                "which is the path separator for your system. Bundler cannot " \
                "function correctly when the Bundle path contains the " \
                "system's PATH separator. Please change your " \
                "bundle path to not match #{path_separator.inspect}." \
                "\nYour current bundle path is '#{Bundler.bundle_path}'."
      raise Bundler::PathError, message
    end

    def find_gemfile
      given = ENV["BUNDLE_GEMFILE"]
      return given if given && !given.empty?
      find_file(*gemfile_names)
    end

    def gemfile_names
      ["gems.rb", "Gemfile"]
    end

    def find_file(*names)
      search_up(*names) do |filename|
        return filename if File.file?(filename)
      end
    end

View on GitHub (pinned to 0e5b888e1c)

Solutions

  1. Set BUNDLE_PATH (or `bundle config set path`) to a single directory with no separator characters, e.g. vendor/bundle
  2. Fix the CI/CD template or script that builds the variable from a joined list
  3. Temporarily `bundle config unset path` to fall back to the default install location and confirm everything else works

Example fix

# before
$ BUNDLE_PATH="C:/gems;D:/gems" bundle install
# Your bundle path contains text matching ";" ...

# after
$ BUNDLE_PATH="C:/gems" bundle install
Defensive patterns

Strategy: validation

Validate before calling

def safe_bundle_path?(path)
  s = path.to_s
  !s.empty? && s.count(Gem.path_separator).zero?
end

Try / catch

begin
  Bundler.ui = ... # any early bundler setup that validates settings
  # e.g. Bundler.configure if exposing internals in a wrapper tool
rescue Bundler::PathError => e
  abort "fix BUNDLE_PATH (contains #{Gem.path_separator.inspect}): #{e.message}"
end

Prevention

When it happens

Trigger: BUNDLE_PATH assembled by string-joining several directories with File::PATH_SEPARATOR; copy-pasted Windows config embedding ';' inside the value; CI templates that accidentally append $PATH or $GEM_PATH into BUNDLE_PATH via naive interpolation.

Common situations: Docker/CI variable templating bugs that concatenate lists; values pasted from documentation examples of GEM_PATH (which IS a list) into BUNDLE_PATH (which is a single directory); misconfigured deployment tooling.

Related errors


AI-assisted analysis of ruby/ruby@0e5b888e1c (2026-08-21). Data as JSON: /api/errors/87fd6f5f5a8ecff8. Report an issue: GitHub.