diem/diem · error · anyhow::Error
No initial command
Error message
No initial command
What it means
taskify buckets consecutive non-empty lines of a test file into tasks; a bucket that produced no commands at the very first position means the file starts with a blank/empty command bucket. The harness bails because a task stream must begin with at least one command to attach directives to.
Source
Thrown at language/testing-infra/transactional-test-runner/src/tasks.rs:90
} else if WHITESPACE.is_match(&line) {
in_command = false;
continue;
} else {
in_command = false;
cur_text.push((line_number, line))
}
}
bucketed_lines.push((cur_commands, cur_text));
if bucketed_lines.is_empty() {
return Ok(vec![]);
}
let mut tasks = vec![];
for (number, (commands, text)) in bucketed_lines.into_iter().enumerate() {
if commands.is_empty() {
assert!(number == 0);
bail!("No initial command")
}
let start_line = commands.first().unwrap().0;
let command_lines_stop = commands.last().unwrap().0;
let mut command_text = "task ".to_string();
for (line_number, text) in commands {
assert!(!text.is_empty(), "{}: {}", line_number, text);
command_text = format!("{} {}", command_text, text);
}
let command_split = command_text.split_ascii_whitespace().collect::<Vec<_>>();
let name_opt = command_split.get(1).map(|s| (*s).to_owned());
let command = match Command::from_iter_safe(command_split) {
Ok(command) => command,
Err(e) => {
let mut spit_iter = command_text.split_ascii_whitespace();
// skip 'task'
spit_iter.next();
let help_command = match spit_iter.next() {View on GitHub (pinned to fc4714a8ea)
Solutions
- Ensure the test file starts with a valid command directive (e.g. '//# run ...' or '// options ...') and no leading empty bucket
- Remove stray blank/comment-only lines at the top of the file so the first bucket contains a command
- Verify you passed the correct file path to the test runner
Example fix
// before //# run 0x1::m::f // after (command on the first bucket) //# run 0x1::m::f
Defensive patterns
Strategy: validation
Validate before calling
// Before calling taskify, check the file starts with a command bucket
let first_bucket_has_command = lines.iter()
.find(|l| !l.trim().is_empty())
.map_or(false, |l| l.trim_start().starts_with("//#"));
assert!(first_bucket_has_command, "test file must begin with a //# command directive"); Try / catch
match taskify(text) {
Err(e) if e.to_string() == "No initial command" => {
bail!("Test file is empty or starts without a command directive; add e.g. '//# run ...' at the top")
}
other => other,
} Prevention
- Start every .move test file with a directive (//# run, //# init, etc.)
- Do not leave blank/comment-only buckets at the very top of the file
- Sanity-check the file passed to the runner is the intended non-empty test
When it happens
Trigger: Running taskify on a .move test file whose first bucketed line group contains no parseable commands (empty file, or the first bucket is empty) — the assert!(number == 0) confirms this only fires for the first bucket.
Common situations: A test file that begins with blank lines or only comments so the first bucket has zero commands; malformed directive syntax at the top of the file that parses to no commands; accidentally passing an empty or wrong file to taskify.
Related errors
- Invalid command. Got error {} Lines {} - {}. {}
- Failed to parse address. Got error: {}
- Invalid module access. Did not expect type arguments
- Error: could not find an available port
- fail to set actions for failpoint
AI-assisted analysis of diem/diem@fc4714a8ea (2026-09-04).
Data as JSON: /api/errors/198d3b94a187cd3a.
Report an issue: GitHub.