diff -r df35b5b7b6a4 -r a11e25bdd247 src/Tools/Code/code_target.ML --- a/src/Tools/Code/code_target.ML Fri Apr 14 22:55:01 2023 +0200 +++ b/src/Tools/Code/code_target.ML Tue Apr 04 16:06:12 2023 +0200 @@ -311,9 +311,14 @@ (case pretty_modules of Singleton (_, p) => Bytes.write root (format p) | Hierarchy code_modules => - (Isabelle_System.make_directory root; - List.app (fn (names, p) => - Bytes.write (Path.appends (root :: map Path.basic names)) (format p)) code_modules)); + List.app (fn (names, p) => + let + val segments = map Path.basic names; + in + Isabelle_System.make_directory (Path.appends (root :: (fst (split_last segments)))); + Bytes.write (Path.appends (root :: segments)) (format p) + end) + code_modules); in