`spawn("sub/prog")` of a file that is missing or not executable reports a PATH search

Open Beginner friendly
#631 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
83/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli, testing

Research direction

Start in spawn.rs at resolve and the call site around line 89, then read the test a_program_with_a_directory_part_is_found_from_the_working_directory. Add adjacent tests for a non-executable file and a missing file under a directory path. Done when each error reports the underlying permission or missing-file cause instead of a PATH search.

Written by the indexing model from the issue text.

Description

bug good first issue

What happens. #592 made a program name with a directory part resolve from the working directory. On the error path it still falls back to the old PATH search, so the reason shown is wrong:

program in dir termlens Error::Spawn reason std::process::Command
sub/prog, mode 644 Unable to spawn sub/prog because: No viable candidates found in PATH … Permission denied (os error 13)
sub/missing the same PATH message No such file or directory (os error 2)
./sub/prog, mode 644 "… because it is not executable" (correct) —

Cause. resolve (spawn.rs:212-219) returns None when dir/sub/prog is not runnable. spawn.rs:89 then hands sub/prog to portable-pty, which searches only PATH.

Why it matters. The common CI case is target/debug/app downloaded as an artifact without its executable bit. Error::Spawn promises "the reason the OS gave", but a PATH miss sends the reader looking in the wrong place.

Fix. When a name with a directory part exists in dir, return it even if it is not runnable. The exec then fails with EACCES and explain() reports it. For a missing file, report ENOENT against dir/sub/prog instead of searching PATH.

Done when both cases name the real cause, with tests beside a_program_with_a_directory_part_is_found_from_the_working_directory.

Dominant language
Rust
Stars
28
Forks
24
Avg merge
11h 23m
Merged PRs (30d)
42

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vyncint/termlens

All issues in vyncint/termlens

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.