diff --git a/src/dfx/src/lib/builders/motoko.rs b/src/dfx/src/lib/builders/motoko.rs index 0869819747..89b30bc47d 100644 --- a/src/dfx/src/lib/builders/motoko.rs +++ b/src/dfx/src/lib/builders/motoko.rs @@ -165,6 +165,13 @@ impl MotokoBuilder { } }; + std::fs::create_dir_all(motoko_info.get_output_root()).with_context(|| { + format!( + "Failed to create {}.", + motoko_info.get_output_root().to_string_lossy() + ) + })?; + let idl_dir_path = &config.idl_root; std::fs::create_dir_all(idl_dir_path) .with_context(|| format!("Failed to create {}.", idl_dir_path.to_string_lossy()))?; @@ -321,14 +328,7 @@ impl CanisterBuilder for MotokoBuilder { .map(|c| (c.canister_id().to_text(), c.get_name().to_string())) .collect(); - std::fs::create_dir_all(motoko_info.get_output_root()).with_context(|| { - format!( - "Failed to create {}.", - motoko_info.get_output_root().to_string_lossy() - ) - })?; let cache = &self.cache; - get_imports(cache.as_ref(), &motoko_info, &mut *pool.imports.borrow_mut(), pool)?; self.do_build(