Skip to content

Commit 773fb3a

Browse files
committed
support relative XARGO_RUST_SRC
1 parent 28d8a5f commit 773fb3a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/rustc.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ pub struct Src {
4848
impl Src {
4949
pub fn from_env() -> Option<Self> {
5050
env::var_os("XARGO_RUST_SRC").map(|s| {
51-
Src {
52-
path: PathBuf::from(s),
53-
}
51+
let path = PathBuf::from(s);
52+
// To support relative paths, we have to make sure we canonicalize
53+
// before changing the working directory.
54+
let path = path.canonicalize().unwrap_or(path);
55+
Src { path }
5456
})
5557
}
5658

0 commit comments

Comments
 (0)