File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -517,21 +517,21 @@ let run
517517 User_error. raise
518518 [ Pp. textf " Context %S not found!" (Dune_engine.Context_name. to_string name) ])
519519 in
520- ( match
521- List. find contexts ~f: ( fun ctx ->
522- match Context. kind ctx with
523- | Context.Kind. Lock _ -> true
524- | _ -> false )
525- with
526- | Some _ ->
527- User_error. raise
528- [ Pp. text " dune install is not supported with Dune package management. " ]
529- ~hints:
530- [ Pp. concat
531- ~sep: Pp. space
532- [ Pp. text " Use " ; User_message. command " opam " ; Pp. text " instead. " ]
533- ]
534- | None -> () ) ;
520+ let * source_workspace = Memo. run ( Source.Workspace. workspace () ) in
521+ let lock_dir_paths =
522+ Pkg.Pkg_common.Lock_dirs_arg. lock_dirs_of_workspace
523+ Pkg.Pkg_common.Lock_dirs_arg. all
524+ source_workspace
525+ in
526+ if Pkg.Pkg_common. pkg_enabled ~workspace: source_workspace ~lock_dir_paths
527+ then
528+ User_error. raise
529+ [ Pp. text " dune install is not supported with Dune package management. " ]
530+ ~hints:
531+ [ Pp. concat
532+ ~sep: Pp. space
533+ [ Pp. text " Use " ; User_message. command " opam " ; Pp. text " instead. " ]
534+ ] ;
535535 let * pkgs =
536536 match pkgs with
537537 | _ :: _ -> Fiber. return pkgs
Original file line number Diff line number Diff line change @@ -207,6 +207,18 @@ module Lock_dirs_arg = struct
207207 ;;
208208end
209209
210+ let pkg_enabled ~(workspace : Workspace.t ) ~lock_dir_paths =
211+ (* CR-Leonidas-from-XIV: change this logic when we stop detecting lock
212+ directories in the source tree *)
213+ let any_lockdir_exists =
214+ List. exists lock_dir_paths ~f: (fun p -> Fpath. exists (Path.Source. to_string p))
215+ in
216+ match workspace.config.pkg_enabled with
217+ | Set (_ , `Enabled) -> true
218+ | Set (_ , `Disabled) -> false
219+ | Unset -> any_lockdir_exists
220+ ;;
221+
210222let check_pkg_management_enabled () =
211223 Memo. run
212224 @@
Original file line number Diff line number Diff line change @@ -84,4 +84,9 @@ val pp_packages : Dune_pkg.Lock_dir.Pkg.t list -> User_message.Style.t Pp.t
8484
8585(* * [check_pkg_management_enabled ()] checks if package management is enabled in the
8686 workspace configuration. Raises a user error if it is explicitly disabled. *)
87+ val pkg_enabled
88+ : workspace:Workspace. t
89+ -> lock_dir_paths:Path.Source. t list
90+ -> bool
91+
8792val check_pkg_management_enabled : unit -> unit Fiber .t
Original file line number Diff line number Diff line change @@ -14,17 +14,7 @@ let term =
1414 Pkg_common.Lock_dirs_arg. all
1515 workspace
1616 in
17- let any_lockdir_exists =
18- List. exists lock_dir_paths ~f: (fun p -> Fpath. exists (Path.Source. to_string p))
19- in
20- (* CR-Leonidas-from-XIV: change this logic when we stop detecting lock
21- directories in the source tree *)
22- let enabled =
23- match workspace.config.pkg_enabled with
24- | Set (_ , `Enabled) -> true
25- | Set (_ , `Disabled) -> false
26- | Unset -> any_lockdir_exists
27- in
17+ let enabled = Pkg_common. pkg_enabled ~workspace ~lock_dir_paths in
2818 match enabled with
2919 | true -> ()
3020 | false -> exit 1 )
You can’t perform that action at this time.
0 commit comments