From d46c45b63bfc75f882f7a7409bc24ac25365b052 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 25 Apr 2024 15:22:02 +0200 Subject: [PATCH] Look for META files rather than just directories to list plugins If the plugin directory contains anything but directories that each contain a `META` file, loading plugins fails This can happen naturally in particular in the following scenario: - install a package providing a plugin to a command in another package - and remove that plugin package. This leaves an empty directory which triggers that failure. --- otherlibs/dune-site/src/plugins/plugins.ml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/otherlibs/dune-site/src/plugins/plugins.ml b/otherlibs/dune-site/src/plugins/plugins.ml index b65e3de1b1d9..43580df6c5cf 100644 --- a/otherlibs/dune-site/src/plugins/plugins.ml +++ b/otherlibs/dune-site/src/plugins/plugins.ml @@ -1,10 +1,16 @@ open Dune_site.Private_ module Data = Dune_site_plugins_data +let meta_fn = "META" + let readdir dirs = + let ( / ) = Filename.concat in List.concat (List.map - (fun dir -> Array.to_list (Sys.readdir dir)) + (fun dir -> + List.filter + (fun entry -> Sys.file_exists (dir / entry / meta_fn)) + (Array.to_list (Sys.readdir dir))) (List.filter Sys.file_exists dirs)) ;; @@ -208,8 +214,6 @@ let load file ~pkg = { Meta_parser.name = Some pkg; entries } ;; -let meta_fn = "META" - let lookup_and_load_one_dir ~dir ~pkg = let meta_file = Filename.concat dir meta_fn in if Sys.file_exists meta_file