microsoft/edit · error

At least one .lsh file or directory is required

Error message

At least one .lsh file or directory is required

What it means

The lsh binary's run function validates its positional input paths before compiling. If no .lsh files or directories were supplied on the command line, there is nothing for the Generator to read, so it aborts with bail!(). It is a hard CLI usage error, not a runtime failure.

Source

Thrown at crates/lsh-bin/src/main.rs:78

pub fn main() {
    if let Err(e) = run() {
        eprintln!("{e}");
        exit(1);
    }
}

fn run() -> anyhow::Result<()> {
    stdext::arena::init(128 * 1024 * 1024).unwrap();

    let command: Command = argh::from_env();
    let scratch = scratch_arena(None);
    let mut generator = lsh::compiler::Generator::new(&scratch);
    let mut read_lsh = |path: &Path| {
        if path.is_dir() { generator.read_directory(path) } else { generator.read_file(path) }
    };
    let mut read_lsh_inputs = |paths: &[PathBuf]| -> anyhow::Result<()> {
        if paths.is_empty() {
            bail!("At least one .lsh file or directory is required");
        }

        for path in paths {
            read_lsh(path)?;
        }

        Ok(())
    };

    match &command.sub {
        SubCommands::Compile(cmd) => {
            read_lsh_inputs(&cmd.lsh)?;
            let output = generator.generate_rust()?;
            _ = stdout().write_all(output.as_bytes());
        }
        SubCommands::Assembly(cmd) => {
            read_lsh_inputs(&cmd.lsh)?;
            let vt = stdout().is_terminal();

View on GitHub (pinned to 826b4c097b)

Solutions

  1. Pass at least one .lsh file or directory containing highlighting definitions as a positional argument.
  2. Verify the glob/path in your wrapper script actually matches existing files (use `ls` on the pattern) before invoking lsh.
  3. Check CI checkout steps ensure the .lsh sources exist in the working directory.

Example fix

// before
lsh
// after
lsh syntax/ definitions/ || lsh ./syntax.lsh
Defensive patterns

Strategy: validation

Validate before calling

const PATHS: &[&str] = &["syntax/"]; // resolve globs eagerly
let resolved: Vec<PathBuf> = PATHS.iter().flat_map(|p| glob(p).expect("glob")).collect();
if resolved.is_empty() { eprintln!("no .lsh inputs found"); std::process::exit(2); }

Prevention

When it happens

Trigger: Invoking the lsh binary without any positional path arguments (the paths slice passed to read_lsh_inputs is empty), e.g. running `lsh` with no file or directory operands.

Common situations: Forgetting the input path when scripting lsh; a wrapper script that expands a glob to nothing; CI jobs where the .lsh source directory was not checked out or is empty so shell globs expand to zero arguments.

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


AI-assisted analysis of microsoft/edit@826b4c097b (2026-09-06). Data as JSON: /api/errors/3bdfea774c244018. Report an issue: GitHub.