helix-editor/helix · error

--config must specify a path to read

Error message

--config must specify a path to read

What it means

The -c/--config option requires a path to the config file to read; when it is the last argument or the next token is consumed as missing (argv.next() returned None), the parser bails. The value is stored as args.config_file and used instead of the default config.toml for this run.

Source

Thrown at helix-term/src/args.rs:74

                },
                "--hsplit" => match args.split {
                    Some(_) => anyhow::bail!("can only set a split once of a specific type"),
                    None => args.split = Some(Layout::Horizontal),
                },
                "--health" => {
                    args.health = true;
                    args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
                }
                "-g" | "--grammar" => match argv.next().as_deref() {
                    Some("fetch") => args.fetch_grammars = true,
                    Some("build") => args.build_grammars = true,
                    _ => {
                        anyhow::bail!("--grammar must be followed by either 'fetch' or 'build'")
                    }
                },
                "-c" | "--config" => match argv.next().as_deref() {
                    Some(path) => args.config_file = Some(path.into()),
                    None => anyhow::bail!("--config must specify a path to read"),
                },
                "--log" => match argv.next().as_deref() {
                    Some(path) => args.log_file = Some(path.into()),
                    None => anyhow::bail!("--log must specify a path to write"),
                },
                "-w" | "--working-dir" => match argv.next().as_deref() {
                    Some(path) => {
                        args.working_directory = if Path::new(path).is_dir() {
                            Some(PathBuf::from(path))
                        } else {
                            anyhow::bail!(
                                "--working-dir specified does not exist or is not a directory"
                            )
                        }
                    }
                    None => {
                        anyhow::bail!("--working-dir must specify an initial working directory")
                    }

View on GitHub (pinned to 079a789e8c)

Solutions

  1. Provide the path: hx -c /path/to/config.toml file.txt
  2. Quote paths with spaces: hx -c "my config.toml"
  3. Note ~ is expanded by the shell, not Helix - keep it unquoted or use $HOME explicitly

Example fix

# before
hx -c

# after
hx -c ~/.config/helix/config.toml main.rs
Defensive patterns

Strategy: validation

Validate before calling

# Shell: fail fast when the config path is missing/unreadable
CFG="${CFG:-$HOME/.config/helix/config.toml}"
[ -r "$CFG" ] || { echo "config not readable: $CFG" >&2; exit 2; }
exec hx -c "$CFG" "$@"

Prevention

When it happens

Trigger: 'hx -c' with nothing after it; trailing space where the shell strips the intended value; 'hx --config' at end of a script line truncated by line-splitting.

Common situations: Line wrapping in docs/scripts losing the path argument; using '~' unquoted so the shell expands oddly; forgetting that --config takes ONE path (not multiple).

Related errors


AI-assisted analysis of helix-editor/helix@079a789e8c (2026-08-16). Data as JSON: /api/errors/c824219c3525b032. Report an issue: GitHub.