jdx/mise · error · eyre::Report
directive requires one argument
Error message
directive requires one argument
What it means
parse_argument, the shared tokenizer for go.work use entries and go.mod module directives, bails when the argument substring handed to it is empty. It is the empty-argument guard at the front of the parser: a directive keyword is present but no path/name token follows it once the line has been comment-stripped and trimmed.
Source
Thrown at src/task/workspace/go.rs:181
if module_path.replace(parsed).is_some() {
bail!("Go module metadata contains multiple module directives");
}
}
module_path.ok_or_else(|| eyre::eyre!("Go module metadata is missing a module directive"))
}
fn directive_arguments<'a>(line: &'a str, directive: &str) -> Option<&'a str> {
let rest = line.strip_prefix(directive)?;
if !rest.starts_with(char::is_whitespace) {
return None;
}
Some(rest.trim())
}
fn parse_argument(value: &str) -> Result<String> {
if value.is_empty() {
bail!("directive requires one argument");
}
if let Some(value) = value.strip_prefix('"') {
let Some(value) = value.strip_suffix('"') else {
bail!("unterminated interpreted Go string");
};
return unescape_go_string(value);
}
if let Some(value) = value.strip_prefix('`') {
let Some(value) = value.strip_suffix('`') else {
bail!("unterminated raw Go string");
};
if value.contains('`') {
bail!("unexpected raw Go string delimiter");
}
return Ok(value.to_string());
}
if value.split_whitespace().count() != 1 {
bail!("directive requires exactly one argument");View on GitHub (pinned to 6f52dcdf99)
Solutions
- Give the directive its single argument: `use ./api` or `module example.com/pkg`
- If the directive is unwanted, delete the whole line rather than emptying it
- Prefer `go work edit` / `go mod edit` over manual text surgery
Example fix
# before (go.work) use # after use ./api
Defensive patterns
Strategy: validation
Validate before calling
fn directive_has_argument(line: &str, keyword: &str) -> bool {
match line.strip_prefix(keyword) {
Some(rest) => !rest.trim().is_empty(),
None => true, // not this directive
}
} Type guard
fn all_directives_have_arguments(contents: &str) -> bool {
contents.lines().all(|raw| {
let line = raw.split("//").next().unwrap_or("").trim();
line != "use" && line != "module"
})
} Try / catch
Err(report) if report.to_string().contains("directive requires one argument") => {
// locate the bare keyword line via the wrapped context ("invalid ... directive on line N") and remove it
remove_bare_directive_lines(&mut contents);
} Prevention
- Delete unwanted directive lines outright instead of blanking their argument
- Generate go.work/go.mod edits with `go work edit` / `go mod edit`
- Fail CI on keyword-only lines in go.work and go.mod
When it happens
Trigger: A `use` or `module` directive whose argument portion is blank after `//` comment stripping and trimming (e.g. a line reduced to the keyword plus separating whitespace by an aggressive edit); programmatic callers passing a pre-trimmed empty token; inside a `use (...)` block, an entry line that carries no argument token.
Common situations: Hand-edits that delete the path but keep the keyword and its whitespace; scripts that rewrite directive arguments to empty strings instead of removing the line; truncated edits during merge conflict resolution.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- directive requires exactly one argument
- unterminated use block
- unterminated interpreted Go string
- unterminated raw Go string
- unexpected raw Go string delimiter
AI-assisted analysis of jdx/mise@6f52dcdf99 (2026-08-22).
Data as JSON: /api/errors/f89d045faf541071.
Report an issue: GitHub.