From 72650b106a475cc05b9b7222e462b28424f257fd Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Thu, 3 Oct 2024 12:03:02 +0100 Subject: [PATCH] Fix ./setup install comand Running ./setup install will give you an error: ``` fromFlag NoFlag. Use fromFlagOrDefault CallStack (from HasCallStack): error, called at src/Distribution/Simple/Flag.hs:110:19 in Cabal-3.15.0.0-inplace:Distribution.Simple.Flag fromFlag, called at src/Distribution/Simple/Register.hs:161:16 in Cabal-3.15.0.0-inplace:Distribution.Simple.Register ``` This seems to not be tested anywhere and most people will use ./setup register in any case, but we should fix this for the next point release in 3.14 series. # Please enter the commit message for your changes. Lines starting Fixes #10416 --- Cabal/src/Distribution/Simple.hs | 1 + .../Install/DistPrefInstall/CHANGELOG.md | 5 +++++ .../DistPrefInstall/DistPrefInstall.cabal | 18 ++++++++++++++++++ .../Install/DistPrefInstall/Setup.hs | 2 ++ .../Install/DistPrefInstall/setup.test.hs | 8 ++++++++ .../Install/DistPrefInstall/src/MyLib.hs | 4 ++++ changelog.d/t10416 | 11 +++++++++++ 7 files changed, 49 insertions(+) create mode 100644 cabal-testsuite/PackageTests/Install/DistPrefInstall/CHANGELOG.md create mode 100644 cabal-testsuite/PackageTests/Install/DistPrefInstall/DistPrefInstall.cabal create mode 100644 cabal-testsuite/PackageTests/Install/DistPrefInstall/Setup.hs create mode 100644 cabal-testsuite/PackageTests/Install/DistPrefInstall/setup.test.hs create mode 100644 cabal-testsuite/PackageTests/Install/DistPrefInstall/src/MyLib.hs create mode 100644 changelog.d/t10416 diff --git a/Cabal/src/Distribution/Simple.hs b/Cabal/src/Distribution/Simple.hs index ada1d6c7aad..3533cf78336 100644 --- a/Cabal/src/Distribution/Simple.hs +++ b/Cabal/src/Distribution/Simple.hs @@ -1094,6 +1094,7 @@ defaultInstallHook_setupHooks inst_hooks pkg_descr localbuildinfo _ flags = do defaultRegisterFlags { regInPlace = installInPlace flags , regPackageDB = installPackageDB flags + , registerCommonFlags = installCommonFlags flags } when (hasLibs pkg_descr) $ register pkg_descr localbuildinfo registerFlags diff --git a/cabal-testsuite/PackageTests/Install/DistPrefInstall/CHANGELOG.md b/cabal-testsuite/PackageTests/Install/DistPrefInstall/CHANGELOG.md new file mode 100644 index 00000000000..3d5552b0ba5 --- /dev/null +++ b/cabal-testsuite/PackageTests/Install/DistPrefInstall/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for DistPrefInstall + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/cabal-testsuite/PackageTests/Install/DistPrefInstall/DistPrefInstall.cabal b/cabal-testsuite/PackageTests/Install/DistPrefInstall/DistPrefInstall.cabal new file mode 100644 index 00000000000..536d26b3648 --- /dev/null +++ b/cabal-testsuite/PackageTests/Install/DistPrefInstall/DistPrefInstall.cabal @@ -0,0 +1,18 @@ +cabal-version: 3.12 +name: DistPrefInstall +version: 0.1.0.0 +license: NONE +author: Matthew Pickering +maintainer: matthewtpickering@gmail.com +build-type: Simple +extra-doc-files: CHANGELOG.md + +common warnings + ghc-options: -Wall + +library + import: warnings + exposed-modules: MyLib + build-depends: base + hs-source-dirs: src + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/Install/DistPrefInstall/Setup.hs b/cabal-testsuite/PackageTests/Install/DistPrefInstall/Setup.hs new file mode 100644 index 00000000000..9a994af677b --- /dev/null +++ b/cabal-testsuite/PackageTests/Install/DistPrefInstall/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/cabal-testsuite/PackageTests/Install/DistPrefInstall/setup.test.hs b/cabal-testsuite/PackageTests/Install/DistPrefInstall/setup.test.hs new file mode 100644 index 00000000000..27b709e7070 --- /dev/null +++ b/cabal-testsuite/PackageTests/Install/DistPrefInstall/setup.test.hs @@ -0,0 +1,8 @@ +import Test.Cabal.Prelude + +main = setupTest $ recordMode DoNotRecord $ withPackageDb $ do + setup "configure" [] + setup "build" [] + setup "copy" [] + setup "install" [] + setup "sdist" [] diff --git a/cabal-testsuite/PackageTests/Install/DistPrefInstall/src/MyLib.hs b/cabal-testsuite/PackageTests/Install/DistPrefInstall/src/MyLib.hs new file mode 100644 index 00000000000..e657c4403f6 --- /dev/null +++ b/cabal-testsuite/PackageTests/Install/DistPrefInstall/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = putStrLn "someFunc" diff --git a/changelog.d/t10416 b/changelog.d/t10416 new file mode 100644 index 00000000000..071b9b1ad95 --- /dev/null +++ b/changelog.d/t10416 @@ -0,0 +1,11 @@ +synopsis: Fix ./setup install command +packages: Cabal +prs: #10417 +issues: #10416 +significance: significant + +description: { + +- `./setup install` was failing with a `fromFlag NoFlag` error. It is now fixed. + +}