Skip to content

Commit

Permalink
Output a readable error for missing Cargo.toml file
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Górny <mgorny@gentoo.org>
  • Loading branch information
mgorny committed Jan 31, 2024
1 parent 2580d08 commit dc7168c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pycargoebuild/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,15 @@ def repack_crates(tar_out: tarfile.TarFile,
crates: typing.Set[Crate] = set()
pkg_metas = []
for directory in args.directory:
with open(directory / "Cargo.toml", "rb") as f:
try:
f = open(directory / "Cargo.toml", "rb")
except FileNotFoundError:
logging.error(f"'Cargo.toml' not found in {str(directory)!r}")
logging.info(
"Please pass the path to a directory containing 'Cargo.toml' "
"as an argument.")
return 1
with f:
workspace = get_workspace_root(directory)
crates.update(workspace.crates)
pkg_metas.append(
Expand Down

0 comments on commit dc7168c

Please sign in to comment.