Code::Blocks Forums

User forums => Help => Topic started by: TonxCruz on September 14, 2021, 12:37:28 pm

Title: Confusing error "No such file or directory" when running a command with `current
Post by: TonxCruz on September 14, 2021, 12:37:28 pm
Just posting here to help others. If you try to run a command with current_dir and you get an error saying "No such file or directory" it's not necessarily the dir path that doesn't exist - it may be the command itself (i. e. the command is not in PATH).
Code
Command::new("this_command_does_not_exist")
    .current_dir("some/valid/path")
    .spawn()
    .expect("command failed to run");
Code
thread 'main' panicked at 'command failed to run: Os { code: 2, kind: NotFound, message: "No such file or directory" }'

Should I file an issue somewhere?
Title: Re: Confusing error "No such file or directory" when running a command with `current
Post by: AndrewCot on September 14, 2021, 01:04:40 pm
Have a read of this post:
https://forums.codeblocks.org/index.php/topic,9996.0.html