Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ fn anchor(shell_override: Option<&str>) {
let cfg_path = venv_path.join("pyvenv.cfg");

if !venv_path.is_dir() || !cfg_path.exists() {
eprintln!(
"uv-shell anchor: no .venv found in {}",
venv_path.parent().unwrap_or(&venv_path).display()
);
return;
}

Expand Down
9 changes: 7 additions & 2 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn help_short_flag() {
// ── anchor (default / bash) ─────────────────────────────────────

#[test]
fn anchor_no_venv_silent() {
fn anchor_no_venv_reports_on_stderr() {
let dir = tmpdir("anchor-none");
let out = Command::new(bin())
.arg("anchor")
Expand All @@ -69,7 +69,12 @@ fn anchor_no_venv_silent() {
assert!(out.status.success());
assert!(
out.stdout.is_empty(),
"anchor should produce no output without .venv"
"anchor should produce no stdout without .venv"
);
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(
stderr.contains("no .venv found"),
"anchor should explain why it produced no output, got: {stderr}"
);
let _ = fs::remove_dir_all(&dir);
}
Expand Down
Loading