From 2d31fc1e4fad34f49eed6ac4a25f0546821fd873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 14 Aug 2024 17:10:39 +0000 Subject: [PATCH] Use absolute path for the current directory This will make it work on Windows as well. --- src/docker_client.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/docker_client.rs b/src/docker_client.rs index 30e559b..a458c81 100644 --- a/src/docker_client.rs +++ b/src/docker_client.rs @@ -64,8 +64,9 @@ impl DockerClient { } fn set_workdir(command: &mut Command) { - let binding = std::env::current_dir().unwrap(); - let current_dir = binding.to_str().unwrap(); + let path = std::env::current_dir().expect("Failed to get current directory"); + let absolute_path = path.canonicalize().expect("Failed to get current directory"); + let current_dir = absolute_path.to_str().expect("Failed to get current directory"); command .arg("-v") @@ -167,7 +168,8 @@ mod tests { assert_eq!(command.get_program(), "docker"); let binding = current_dir().unwrap(); - let current_dir = binding.to_str().unwrap(); + let absolute_path = binding.canonicalize().unwrap(); + let current_dir = absolute_path.to_str().unwrap(); let args: Vec<&OsStr> = command.get_args().collect();