Skip to content

Commit

Permalink
Fix ./setup install comand
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mpickering committed Oct 3, 2024
1 parent 96df6f8 commit 800516b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cabal/src/Distribution/Simple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Revision history for DistPrefInstall

## 0.1.0.0 -- YYYY-mm-dd

* First version. Released on an unsuspecting world.
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/Install/DistPrefInstall/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Test.Cabal.Prelude

main = setupTest $ recordMode DoNotRecord $ withPackageDb $ do
setup "configure" []
setup "build" []
setup "copy" []
setup "install" []
setup "sdist" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
11 changes: 11 additions & 0 deletions changelog.d/t10416
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
synopsis: Fix ./setup install command
packages: Cabal
prs: #10417
issues: #10416
significance: high

description: {

- `./setup install` was failing with a `fromFlag NoFlag` error. It is now fixed.

}

0 comments on commit 800516b

Please sign in to comment.