@@ -1699,6 +1699,33 @@ let merge_conditionals a b =
16991699 { a with packages; solved_for_platforms }
17001700;;
17011701
1702+ let in_source_tree path =
1703+ match (path : Path.t ) with
1704+ | In_source_tree s -> s
1705+ | In_build_dir b ->
1706+ let in_source = Path. drop_build_context_exn path in
1707+ (match Path.Source. explode in_source with
1708+ | "default" :: ".lock" :: components ->
1709+ Path.Source.L. relative Path.Source. root components
1710+ | _otherwise ->
1711+ Code_error. raise
1712+ " Unexpected location of lock directory in build directory"
1713+ [ " path" , Path.Build. to_dyn b; " in_source" , Path.Source. to_dyn in_source ])
1714+ | External e ->
1715+ Code_error. raise
1716+ " External path returned when loading a lock dir"
1717+ [ " path" , Path.External. to_dyn e ]
1718+ ;;
1719+
1720+ let loc_in_source_tree loc =
1721+ loc
1722+ |> Loc. map_pos ~f: (fun ({ pos_fname; _ } as pos ) ->
1723+ let path = Path. of_string pos_fname in
1724+ let new_path = in_source_tree path in
1725+ let pos_fname = Path.Source. to_string new_path in
1726+ { pos with pos_fname })
1727+ ;;
1728+
17021729let check_if_solved_for_platform { solved_for_platforms; _ } ~platform =
17031730 let loc, solved_for_platforms = solved_for_platforms in
17041731 if List. is_empty solved_for_platforms
@@ -1710,6 +1737,7 @@ let check_if_solved_for_platform { solved_for_platforms; _ } ~platform =
17101737 match Solver_env_disjunction. matches_platform solved_for_platforms ~platform with
17111738 | true -> ()
17121739 | false ->
1740+ let loc = loc_in_source_tree loc in
17131741 User_error. raise
17141742 ~loc
17151743 [ Pp. text
0 commit comments