Skip to content
Merged
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
11 changes: 8 additions & 3 deletions py/tools/venv_shim/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use miette::IntoDiagnostic;
use miette::{miette, IntoDiagnostic};
use runfiles::Runfiles;
use which::which;
// Depended on out of rules_rust
use std::env;
use std::env::{self, current_exe};
use std::ffi::OsStr;
use std::fs;
use std::os::unix::process::CommandExt;
Expand Down Expand Up @@ -245,14 +245,19 @@ fn main() -> miette::Result<()> {
let cwd = std::env::current_dir().into_diagnostic()?;
if !executable.is_absolute() {
let candidate = cwd.join(&executable);
if candidate.exists() {
if candidate.exists()
&& !candidate.is_dir()
&& candidate.canonicalize().unwrap() == current_exe().unwrap().canonicalize().unwrap()
{
executable = candidate;
#[cfg(feature = "debug")]
eprintln!(" {:?}", executable);
} else if let Ok(exe) = which(&exec_name) {
executable = exe;
#[cfg(feature = "debug")]
eprintln!(" {:?}", executable);
} else {
return Err(miette!("Unable to identify the real interpreter path!"));
}
}

Expand Down
Loading