From b0e88b1c0bb6d745f9ff7a728c6dcada748a68ea Mon Sep 17 00:00:00 2001
From: Francesco Gazzetta <fgaz@fgaz.me>
Date: Fri, 9 Apr 2021 19:50:57 +0200
Subject: [PATCH] Mark "install --lib" as provisional

And don't encourage its use as much as before. Adding packages to
build-depends is more often what the user wants.
---
 .../src/Distribution/Client/CmdInstall.hs       | 17 ++++++++++++-----
 .../Client/CmdInstall/ClientInstallFlags.hs     |  3 ++-
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/cabal-install/src/Distribution/Client/CmdInstall.hs b/cabal-install/src/Distribution/Client/CmdInstall.hs
index 565cc59aac..f74d0cfa4d 100644
--- a/cabal-install/src/Distribution/Client/CmdInstall.hs
+++ b/cabal-install/src/Distribution/Client/CmdInstall.hs
@@ -156,7 +156,8 @@ installCommand = CommandUI
     ++ "If you want the installed executables to be available globally, "
     ++ "make sure that the PATH environment variable contains that directory. "
     ++ "\n\n"
-    ++ "If TARGET is a library, it will be added to the global environment. "
+    ++ "If TARGET is a library and --lib (provisional) is used, "
+    ++ "it will be added to the global environment. "
     ++ "When doing this, cabal will try to build a plan that includes all "
     ++ "the previously installed libraries. This is currently not implemented."
   , commandNotes        = Just $ \pname ->
@@ -681,10 +682,16 @@ warnIfNoExes verbosity buildCtx =
     "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n" <>
     "@ WARNING: Installation might not be completed as desired! @\n" <>
     "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n" <>
-    "Without flags, the command \"cabal install\" doesn't expose" <>
-    " libraries in a usable manner.  You might have wanted to run" <>
-    " \"cabal install --lib " <>
-    unwords (showTargetSelector <$> selectors) <> "\". "
+    "The command \"cabal install [TARGETS]\" doesn't expose libraries.\n" <>
+    "* You might have wanted to add them as dependencies to your package." <>
+    " In this case add \"" <>
+    intercalate ", " (showTargetSelector <$> selectors) <>
+    "\" to the build-depends field(s) of your package's .cabal file.\n" <>
+    "* You might have wanted to add them to a GHC environment. In this case" <>
+    " use \"cabal install --lib " <>
+    unwords (showTargetSelector <$> selectors) <> "\". " <>
+    " The \"--lib\" flag is provisional: see" <>
+    " https://github.com/haskell/cabal/issues/6481 for more information."
   where
     targets    = concat $ Map.elems $ targetsMap buildCtx
     components = fst <$> targets
diff --git a/cabal-install/src/Distribution/Client/CmdInstall/ClientInstallFlags.hs b/cabal-install/src/Distribution/Client/CmdInstall/ClientInstallFlags.hs
index acfe39a652..ff3c0d6162 100644
--- a/cabal-install/src/Distribution/Client/CmdInstall/ClientInstallFlags.hs
+++ b/cabal-install/src/Distribution/Client/CmdInstall/ClientInstallFlags.hs
@@ -54,7 +54,8 @@ defaultClientInstallFlags = ClientInstallFlags
 clientInstallOptions :: ShowOrParseArgs -> [OptionField ClientInstallFlags]
 clientInstallOptions _ =
   [ option [] ["lib"]
-    "Install libraries rather than executables from the target package."
+    ( "Install libraries rather than executables from the target package " <>
+      "(provisional, see https://github.com/haskell/cabal/issues/6481 for more information)." )
     cinstInstallLibs (\v flags -> flags { cinstInstallLibs = v })
     trueArg
   , option [] ["package-env", "env"]
-- 
GitLab