Skip to content

Commit 6e2363f

Browse files
committed
Bug fix: Use the relative path in the include statement if the target path doesn't exist
1 parent ba5f538 commit 6e2363f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/module.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ impl Input {
184184
};
185185

186186
// TODO: Maybe convert the path earlier in the module building.
187-
let target_path = Path::new(&self.options.target_dir).canonicalize().unwrap();
187+
let relative_path = Path::new(&self.options.target_dir);
188+
// Try to find the root element in an absolute path.
189+
// If the absolute path cannot be constructed due to an error, search the relative path instead.
190+
let target_path = match relative_path.canonicalize() {
191+
Ok(path) => path,
192+
Err(_) => relative_path.to_path_buf(),
193+
};
188194

189195
// Split the target path into components
190196
let mut component_vec: Vec<_> = target_path

0 commit comments

Comments
 (0)