diff --git a/src/machine/loader.rs b/src/machine/loader.rs index 91d41c7f..e713916f 100644 --- a/src/machine/loader.rs +++ b/src/machine/loader.rs @@ -1270,8 +1270,11 @@ impl Machine { pub(crate) fn load_context_directory(&mut self) { if let Some(load_context) = self.load_contexts.last() { - if let Some(directory) = load_context.path.ancestors().next() { + if let Some(directory) = load_context.path.parent() { + // canonicalize returns the absolute path of the directory. + let directory = directory.canonicalize().unwrap(); let directory_str = directory.to_str().unwrap(); + let directory_atom = clause_name!(directory_str.to_string(), self.machine_st.atom_tbl);