jdx/mise · error
directive requires one argument
Error message
directive requires one argument
What it means
parse_argument parses the argument of a Go directive (module, use) in go.work/go.mod. An empty argument — nothing after the directive keyword, or only whitespace — cannot name a directory or module path, so it bails with 'directive requires one argument'.
Solutions
- Give the directive an argument: `use ./dir` or `module example.com/m`.
- Delete the empty directive line entirely.
- Wrap multiple entries in a use block properly (`use ( ... )`) instead of repeating a bare `use`.
Example fix
// before (go.work) use // after use ./services/api
Defensive patterns
Strategy: validation
Validate before calling
// shell
awk '$1=="use" && NF<2 && $0 !~ /\($/ && $0 !~ /^use[ \t]*\($/ {print "bare directive: " $0; bad=1} END{exit bad}' go.work Prevention
- Always give `use`/`module` a value on the same line
- If you comment out a directive, comment the whole line (`// use ./x`), not just the value
- Regenerate files with go CLI rather than hand-stripping lines
When it happens
Trigger: go.work has `use` with no argument, or inside a use block an empty/whitespace-only line survives comment stripping and trimming, then reaches parse_argument; same for a bare `module` line in go.mod.
Common situations: Editing go.work and leaving a dangling `use` line; a commented-out value (`use // ./x`) leaving only the keyword; generated files with blank lines inside a use block (blank lines are skipped, but keyword-only lines are not).
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
- Go module metadata contains multiple module directives
- unexpected raw Go string delimiter
- unterminated interpreted Go string
- unterminated raw Go string
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/f89d045faf541071.
Report an issue: GitHub.
Appendix: 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 533346cc37)