{"record":{"id":"b3c755ad72091a02","repo":"ruby/ruby","slug":"cannot-specify-path-option-without-a-value","errorCode":null,"errorMessage":"Cannot specify `--path` option without a value","messagePattern":"Cannot specify `--path` option without a value","errorType":"exception","errorClass":"InvalidOption","httpStatus":null,"severity":"error","filePath":"lib/bundler/cli/open.rb","lineNumber":13,"sourceCode":"# frozen_string_literal: true\n\nmodule Bundler\n  class CLI::Open\n    attr_reader :options, :name, :path\n    def initialize(options, name)\n      @options = options\n      @name = name\n      @path = options[:path] unless options[:path].nil?\n    end\n\n    def run\n      raise InvalidOption, \"Cannot specify `--path` option without a value\" if !@path.nil? && @path.empty?\n      editor = [ENV[\"BUNDLER_EDITOR\"], ENV[\"VISUAL\"], ENV[\"EDITOR\"]].find {|e| !e.nil? && !e.empty? }\n      return Bundler.ui.info(\"To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR\") unless editor\n      return unless spec = Bundler::CLI::Common.select_spec(name, :regex_match)\n      if spec.default_gem?\n        Bundler.ui.info \"Unable to open #{name} because it's a default gem, so the directory it would normally be installed to does not exist.\"\n      else\n        root_path = spec.full_gem_path\n        command = editor_command(editor) << File.join([root_path, path].compact)\n        Bundler.with_original_env do\n          system(*command, { chdir: root_path })\n        end || Bundler.ui.info(\"Could not run '#{command.join(\" \")}'\")\n      end\n    end\n\n    def editor_command(editor)\n      # On Windows an editor is often configured with a full path such as\n      # C:\\Program Files\\Microsoft VS Code\\Code.exe, which shell splitting\n      # would corrupt. Take a value that names an existing file as a","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/ruby/ruby/blob/0e5b888e1c355f3f728f2659f085820937dada48/lib/bundler/cli/open.rb#L1-L31","documentation":"CLI::Open (lib/bundler/cli/open.rb:13) implements `bundle open GEM --path <relative-path>` to open a subdirectory of the gem in your editor. The constructor keeps options[:path] when non-nil, and run raises Bundler::InvalidOption if that value is present but empty — an empty string would produce a meaningless File.join and an editor launched at an invalid path.","triggerScenarios":"`bundle open rack --path ''` or `--path \"\"`, typically when the value comes from a shell variable that is set but empty (e.g. $MY_GEM_SUBDIR unset with set -u style quoting producing \"\").","commonSituations":"Scripts parameterizing the subpath with a variable that is occasionally empty; CI env vars defined as blank strings; a trailing `--path` with an accidentally empty quoted argument.","solutions":["Pass a real relative path inside the gem: `bundle open rack --path lib/rack`","If the value is optional in your script, omit the --path flag entirely when it is empty","Default the variable: `--path \"${SUBDIR:-lib}\"`"],"exampleFix":"# before\n$ bundle open nokogiri --path \"\"\n# => Cannot specify `--path` option without a value\n\n# after\n$ bundle open nokogiri --path ext/nokogiri","handlingStrategy":"validation","validationCode":"subpath = ENV['GEM_SUBPATH']\nargs = %w[bundle open mygem]\nargs += ['--path', subpath] if subpath && !subpath.strip.empty?\nsystem(*args)","typeGuard":"def usable_open_path?(value)\n  !value.nil? && !value.empty?\nend","tryCatchPattern":"begin\n  Bundler::CLI::Open.new(options, name).run\nrescue Bundler::InvalidOption => e\n  warn e.message\n  exit 1\nend","preventionTips":["Only pass --path when the variable is non-empty","Default subpaths in wrappers: ${SUBPATH:-lib}"],"tags":["bundler","cli","open","editor","empty-argument"],"backgroundTag":"missing-option-value","analyzedSha":"0e5b888e1c355f3f728f2659f085820937dada48","analyzedAt":"2026-08-21T14:25:43.473Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}