Skip to content

Commit 0e819cd

Browse files
authored
Merge pull request #26 from rails/absolute-path
Use absolute path for the current directory
2 parents 3d44bda + 2d31fc1 commit 0e819cd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/docker_client.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ impl DockerClient {
6464
}
6565

6666
fn set_workdir(command: &mut Command) {
67-
let binding = std::env::current_dir().unwrap();
68-
let current_dir = binding.to_str().unwrap();
67+
let path = std::env::current_dir().expect("Failed to get current directory");
68+
let absolute_path = path.canonicalize().expect("Failed to get current directory");
69+
let current_dir = absolute_path.to_str().expect("Failed to get current directory");
6970

7071
command
7172
.arg("-v")
@@ -167,7 +168,8 @@ mod tests {
167168
assert_eq!(command.get_program(), "docker");
168169

169170
let binding = current_dir().unwrap();
170-
let current_dir = binding.to_str().unwrap();
171+
let absolute_path = binding.canonicalize().unwrap();
172+
let current_dir = absolute_path.to_str().unwrap();
171173

172174
let args: Vec<&OsStr> = command.get_args().collect();
173175

0 commit comments

Comments
 (0)