Repository navigation
Closed
Description
Describe the bug
cabal install rebuilds all dependencies after a cabal build in windows
To Reproduce
Steps to reproduce the behavior:
- A simple cabal project with only one dependency
say - First we build the project using a fresh store dir and print the store contents and the cabal-plan fingerprint
D:\ws\haskell\cabal-test>cabal clean
D:\ws\haskell\cabal-test>rmdir sr /s /q
D:\ws\haskell\cabal-test>cabal --store-dir .\sr build
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- say-0.1.0.1 (lib) (requires build)
- cabal-test-0.1.0.0 (lib) (first run)
- cabal-test-0.1.0.0 (exe:cabal-test) (first run)
Configuring library for say-0.1.0.1..
Preprocessing library for say-0.1.0.1..
Building library for say-0.1.0.1..
.....................
Installing library in D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-13304\ws\haskell\cabal-test\sr\ghc-8.6.5\say-0.1.0.1-9d85f3e60b43742f757835053a7ea996c1c596e4\lib
Configuring library for cabal-test-0.1.0.0..
Preprocessing library for cabal-test-0.1.0.0..
Building library for cabal-test-0.1.0.0..
............
Configuring executable 'cabal-test' for cabal-test-0.1.0.0..
Preprocessing executable 'cabal-test' for cabal-test-0.1.0.0..
Building executable 'cabal-test' for cabal-test-0.1.0.0..
.......................
Linking D:\ws\haskell\cabal-test\dist-newstyle\build\x86_64-windows\ghc-8.6.5\cabal-test-0.1.0.0\x\cabal-test\build\cabal-test\cabal-test.exe ...
D:\ws\haskell\cabal-test>dir sr\ghc-8.6.5 /b
incoming
package.db
say-0.1.0.1-9d85f3e60b43742f757835053a7ea996c1c596e4
D:\ws\haskell\cabal-test>cabal-plan fingerprint
________________________________________________________________ B array-0.5.3.0
________________________________________________________________ B base-4.12.0.0
________________________________________________________________ B binary-0.8.6.0
________________________________________________________________ B bytestring-0.10.8.2
________________________________________________________________ L cabal-test-0.1.0.0
________________________________________________________________ B containers-0.6.0.1
________________________________________________________________ B deepseq-1.4.4.0
________________________________________________________________ B ghc-prim-0.5.3
________________________________________________________________ B integer-gmp-1.0.2.0
________________________________________________________________ B rts-1.0
f639656fc21925c45f3f55769b9fb7a90699e943376a725e215a5deea473b3e4 G say-0.1.0.1
________________________________________________________________ B text-1.2.3.1
________________________________________________________________ B transformers-0.5.6.2
- Then we install the project using the same store dir
- Another bug: you can set a relative dir for the store using
cabal buildbut no usingcabal install
- Another bug: you can set a relative dir for the store using
D:\ws\haskell\cabal-test>cabal --store-dir .\sr install --builddir dist2
Wrote tarball sdist to
D:\ws\haskell\cabal-test\dist2\sdist\cabal-test-0.1.0.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- say-0.1.0.1 (lib) (requires build)
- cabal-test-0.1.0.0 (lib) (requires build)
- cabal-test-0.1.0.0 (exe:cabal-test) (requires build)
Configuring library for say-0.1.0.1..
cabal-3.6.2.0.exe: expected an absolute directory name for --prefix:
.\sr\ghc-8.6.5\say-0.1.0.1-f56dd8dcb828e676e2fe979752cedce7d5e3ea47
cabal-3.6.2.0.exe: Failed to build say-0.1.0.1 (which is required by
exe:cabal-test from cabal-test-0.1.0.0). The failure occurred during the
configure step.
D:\ws\haskell\cabal-test>cabal --store-dir D:\ws\haskell\cabal-test\sr install -
-builddir dist2
Wrote tarball sdist to
D:\ws\haskell\cabal-test\dist2\sdist\cabal-test-0.1.0.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- say-0.1.0.1 (lib) (requires build)
- cabal-test-0.1.0.0 (lib) (requires build)
- cabal-test-0.1.0.0 (exe:cabal-test) (requires build)
Configuring library for say-0.1.0.1..
Preprocessing library for say-0.1.0.1..
Building library for say-0.1.0.1..
................
Installing library in D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-10896\ws\haskell\cabal-test\sr\ghc-8.6.5\say-0.1.0.1-f56dd8dcb828e676e2fe979752cedce7d5
e3ea47\lib
Configuring library for cabal-test-0.1.0.0..
Preprocessing library for cabal-test-0.1.0.0..
Building library for cabal-test-0.1.0.0..
..............
Installing library in D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-10896\ws\haskell\cabal-test\sr\ghc-8.6.5\cabal-test-0.1.0.0-cfcb93c3d8595a655927c100ce79bbdaaf168f88\lib
Configuring executable 'cabal-test' for cabal-test-0.1.0.0..
Preprocessing executable 'cabal-test' for cabal-test-0.1.0.0..
Building executable 'cabal-test' for cabal-test-0.1.0.0..
...................
Linking dist\build\cabal-test\cabal-test.exe ...
Installing executable cabal-test in D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-10896\ws\haskell\cabal-test\sr\ghc-8.6.5\cabal-test-0.1.0.0-9848e717cfed9
d05e08950e4e5de83d054a50961\bin
Warning: The directory
D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-10896\ws\haskell\cabal-test\sr\ghc-8.6.5\cabal-test-0.1.0.0-9848e717cfed9d05e08950e4e5de83d054a50961\bin
is not in the system search path.
Symlinking 'cabal-test.exe' to 'D:\cabal\bin\cabal-test.exe'
D:\ws\haskell\cabal-test>dir sr\ghc-8.6.5 /b
cabal-test-0.1.0.0-9848e717cfed9d05e08950e4e5de83d054a50961
cabal-test-0.1.0.0-cfcb93c3d8595a655927c100ce79bbdaaf168f88
incoming
package.db
say-0.1.0.1-9d85f3e60b43742f757835053a7ea996c1c596e4
say-0.1.0.1-f56dd8dcb828e676e2fe979752cedce7d5e3ea47
D:\ws\haskell\cabal-test>cabal-plan fingerprint --builddir=dist2
________________________________________________________________ B array-0.5.3.0
________________________________________________________________ B base-4.12.0.0
________________________________________________________________ B binary-0.8.6.0
________________________________________________________________ B bytestring-0.10.8.2
________________________________________________________________ L cabal-test-0.1.0.0
________________________________________________________________ B containers-0.6.0.1
________________________________________________________________ B deepseq-1.4.4.0
________________________________________________________________ B ghc-prim-0.5.3
________________________________________________________________ B integer-gmp-1.0.2.0
________________________________________________________________ B rts-1.0
f639656fc21925c45f3f55769b9fb7a90699e943376a725e215a5deea473b3e4 G say-0.1.0.1
________________________________________________________________ B text-1.2.3.1
________________________________________________________________ B transformers-0.5.6.2
D:\ws\haskell\cabal-test>cabal-plan diff --builddir=dist-newstyle --builddir=dist2
(No output, lovely)
- As you can check
cabal-plan diffdoes not output anything, from other tests it seems it is broken in windows, including in the msys2 shell - After deleting the store we do the same in reverse order, this time preserving the temp build dir used by
cabal install- There is no flag to preserve the directory, we have to copy the tmp dir quickly 🤦
D:\ws\haskell\cabal-test> rmdir sr /s /q
D:\ws\haskell\cabal-test>cabal --store-dir D:\ws\haskell\cabal-test\sr install -builddir dist2
Wrote tarball sdist to
D:\ws\haskell\cabal-test\dist2\sdist\cabal-test-0.1.0.0.tar.gz
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- say-0.1.0.1 (lib) (requires build)
- cabal-test-0.1.0.0 (lib) (requires build)
- cabal-test-0.1.0.0 (exe:cabal-test) (requires build)
Configuring library for say-0.1.0.1..
Preprocessing library for say-0.1.0.1..
Building library for say-0.1.0.1..
............................
Installing library in D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-10896\s\haskell\cabal-test\sr\ghc-8.6.5\say-0.1.0.1-f56dd8dcb828e676e2fe979752cedce7de3ea47\lib
Configuring library for cabal-test-0.1.0.0..
Preprocessing library for cabal-test-0.1.0.0..
Building library for cabal-test-0.1.0.0..
..................
Installing library in D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-10896\s\haskell\cabal-test\sr\ghc-8.6.5\cabal-test-0.1.0.0-cfcb93c3d8595a655927c100ce9bbdaaf168f88\lib
Configuring executable 'cabal-test' for cabal-test-0.1.0.0..
Preprocessing executable 'cabal-test' for cabal-test-0.1.0.0..
Building executable 'cabal-test' for cabal-test-0.1.0.0..
..................
Linking dist\build\cabal-test\cabal-test.exe ...
Installing executable cabal-test in D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incomng\new-10896\ws\haskell\cabal-test\sr\ghc-8.6.5\cabal-test-0.1.0.0-9848e717cfedd05e08950e4e5de83d054a50961\bin
Warning: The directory
D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-10896\ws\haskell\cabal-test\r\ghc-8.6.5\cabal-test-0.1.0.0-9848e717cfed9d05e08950e4e5de83d054a50961\bin is not in the system search path.
Symlinking 'cabal-test.exe' to 'D:\cabal\bin\cabal-test.exe'
cabal-3.6.2.0.exe: Path 'D:\cabal\bin\cabal-test' already exists. Use --overwrite-policy=always to overwrite.
D:\ws\haskell\cabal-test>dir sr\ghc-8.6.5 /b
cabal-test-0.1.0.0-9848e717cfed9d05e08950e4e5de83d054a50961
cabal-test-0.1.0.0-cfcb93c3d8595a655927c100ce79bbdaaf168f88
incoming
package.db
say-0.1.0.1-f56dd8dcb828e676e2fe979752cedce7d5e3ea47
- the fingerprint for
sayis the same in the temp build dir
D:\ws\haskell\cabal-test>cabal-plan fingerprint --builddir=tmp2\cabal-install.-1
0896\dist2
________________________________________________________________ B array-0.5.3.0
________________________________________________________________ B base-4.12.0.0
________________________________________________________________ B binary-0.8.6.0
________________________________________________________________ B bytestring-0.10.8.2
14aa96bfe9d34856cf85a09bc4b314aac137e5e325f3f4beeb77b70ebc57a4a6 G cabal-test-0.1.0.0
________________________________________________________________ B containers-0.6.0.1
________________________________________________________________ B deepseq-1.4.4.0
________________________________________________________________ B ghc-prim-0.5.3
________________________________________________________________ B integer-gmp-1.0.2.0
________________________________________________________________ B rts-1.0
f639656fc21925c45f3f55769b9fb7a90699e943376a725e215a5deea473b3e4 G say-0.1.0.1
________________________________________________________________ B text-1.2.3.1
________________________________________________________________ B transformers-0.5.6.2
- we do the build after the install, deps are rebuilt again:
D:\ws\haskell\cabal-test>cabal --store-dir .\sr build
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- say-0.1.0.1 (lib) (requires build)
- cabal-test-0.1.0.0 (lib) (dependency rebuilt)
- cabal-test-0.1.0.0 (exe:cabal-test) (dependency rebuilt)
Configuring library for say-0.1.0.1..
Preprocessing library for say-0.1.0.1..
Building library for say-0.1.0.1..
[1 of 2] Compiling Paths_say ( dist\build\autogen\Paths_say.hs, dist\buil
d\Paths_say.o )
[2 of 2] Compiling Say ( src\Say.hs, dist\build\Say.o )
Installing library in D:\ws\haskell\cabal-test\sr\ghc-8.6.5\incoming\new-9200\ws
\haskell\cabal-test\sr\ghc-8.6.5\say-0.1.0.1-9d85f3e60b43742f757835053a7ea996c1c
596e4\lib
Preprocessing library for cabal-test-0.1.0.0..
Building library for cabal-test-0.1.0.0..
Preprocessing executable 'cabal-test' for cabal-test-0.1.0.0..
Building executable 'cabal-test' for cabal-test-0.1.0.0..
D:\ws\haskell\cabal-test>dir sr\ghc-8.6.5 /b
cabal-test-0.1.0.0-9848e717cfed9d05e08950e4e5de83d054a50961
cabal-test-0.1.0.0-cfcb93c3d8595a655927c100ce79bbdaaf168f88
incoming
package.db
say-0.1.0.1-9d85f3e60b43742f757835053a7ea996c1c596e4
say-0.1.0.1-f56dd8dcb828e676e2fe979752cedce7d5e3ea47
- output of
cabal infofor all the three build dirs involved:
cabal info
# cabal-plan info --builddir=dist-newstyle
Tree
~~~~
cabal-test-0.1.0.0
[cabal-test-0.1.0.0:exe:"cabal-test"]
├─ base-4.12.0.0
│ ├─ ghc-prim-0.5.3
│ │ └─ rts-1.0
│ ├─ integer-gmp-1.0.2.0
│ │ └─ ghc-prim-0.5.3 ┄┄
│ └─ rts-1.0 ┄┄
├─ bytestring-0.10.8.2
│ ├─ base-4.12.0.0 ┄┄
│ ├─ deepseq-1.4.4.0
│ │ ├─ array-0.5.3.0
│ │ │ └─ base-4.12.0.0 ┄┄
│ │ └─ base-4.12.0.0 ┄┄
│ ├─ ghc-prim-0.5.3 ┄┄
│ └─ integer-gmp-1.0.2.0 ┄┄
└─ cabal-test-0.1.0.0
├─ base-4.12.0.0 ┄┄
├─ bytestring-0.10.8.2 ┄┄
├─ say-0.1.0.1
│ ├─ base-4.12.0.0 ┄┄
│ ├─ bytestring-0.10.8.2 ┄┄
│ ├─ text-1.2.3.1
│ │ ├─ array-0.5.3.0 ┄┄
│ │ ├─ base-4.12.0.0 ┄┄
│ │ ├─ binary-0.8.6.0
│ │ │ ├─ array-0.5.3.0 ┄┄
│ │ │ ├─ base-4.12.0.0 ┄┄
│ │ │ ├─ bytestring-0.10.8.2 ┄┄
│ │ │ └─ containers-0.6.0.1
│ │ │ ├─ array-0.5.3.0 ┄┄
│ │ │ ├─ base-4.12.0.0 ┄┄
│ │ │ ├─ deepseq-1.4.4.0 ┄┄
│ │ │ └─ ghc-prim-0.5.3 ┄┄
│ │ ├─ bytestring-0.10.8.2 ┄┄
│ │ ├─ deepseq-1.4.4.0 ┄┄
│ │ ├─ ghc-prim-0.5.3 ┄┄
│ │ └─ integer-gmp-1.0.2.0 ┄┄
│ └─ transformers-0.5.6.2
│ └─ base-4.12.0.0 ┄┄
└─ text-1.2.3.1 ┄┄
Top-sorted
~~~~~~~~~~
UnitId "rts"
UnitId "ghc-prim-0.5.3"
UnitId "integer-gmp-1.0.2.0"
UnitId "base-4.12.0.0"
UnitId "array-0.5.3.0"
UnitId "deepseq-1.4.4.0"
UnitId "bytestring-0.10.8.2"
UnitId "containers-0.6.0.1"
UnitId "binary-0.8.6.0"
UnitId "text-1.2.3.1"
UnitId "transformers-0.5.6.2"
UnitId "say-0.1.0.1-9d85f3e60b43742f757835053a7ea996c1c596e4"
UnitId "cabal-test-0.1.0.0-inplace"
UnitId "cabal-test-0.1.0.0-inplace-cabal-test"
Direct deps
~~~~~~~~~~~
PkgId (PkgName "cabal-test") (Ver [0,1,0,0])
CompNameLib
base-4.12.0.0
bytestring-0.10.8.2
say-0.1.0.1
text-1.2.3.1
PkgId (PkgName "cabal-test") (Ver [0,1,0,0])
CompNameExe "cabal-test"
base-4.12.0.0
bytestring-0.10.8.2
cabal-test-0.1.0.0
# cabal-plan info --builddir=dist2
Tree
~~~~
cabal-test-0.1.0.0
[cabal-test-0.1.0.0:exe:"cabal-test"]
├─ base-4.12.0.0
│ ├─ ghc-prim-0.5.3
│ │ └─ rts-1.0
│ ├─ integer-gmp-1.0.2.0
│ │ └─ ghc-prim-0.5.3 ┄┄
│ └─ rts-1.0 ┄┄
├─ bytestring-0.10.8.2
│ ├─ base-4.12.0.0 ┄┄
│ ├─ deepseq-1.4.4.0
│ │ ├─ array-0.5.3.0
│ │ │ └─ base-4.12.0.0 ┄┄
│ │ └─ base-4.12.0.0 ┄┄
│ ├─ ghc-prim-0.5.3 ┄┄
│ └─ integer-gmp-1.0.2.0 ┄┄
└─ cabal-test-0.1.0.0
├─ base-4.12.0.0 ┄┄
├─ bytestring-0.10.8.2 ┄┄
├─ say-0.1.0.1
│ ├─ base-4.12.0.0 ┄┄
│ ├─ bytestring-0.10.8.2 ┄┄
│ ├─ text-1.2.3.1
│ │ ├─ array-0.5.3.0 ┄┄
│ │ ├─ base-4.12.0.0 ┄┄
│ │ ├─ binary-0.8.6.0
│ │ │ ├─ array-0.5.3.0 ┄┄
│ │ │ ├─ base-4.12.0.0 ┄┄
│ │ │ ├─ bytestring-0.10.8.2 ┄┄
│ │ │ └─ containers-0.6.0.1
│ │ │ ├─ array-0.5.3.0 ┄┄
│ │ │ ├─ base-4.12.0.0 ┄┄
│ │ │ ├─ deepseq-1.4.4.0 ┄┄
│ │ │ └─ ghc-prim-0.5.3 ┄┄
│ │ ├─ bytestring-0.10.8.2 ┄┄
│ │ ├─ deepseq-1.4.4.0 ┄┄
│ │ ├─ ghc-prim-0.5.3 ┄┄
│ │ └─ integer-gmp-1.0.2.0 ┄┄
│ └─ transformers-0.5.6.2
│ └─ base-4.12.0.0 ┄┄
└─ text-1.2.3.1 ┄┄
Top-sorted
~~~~~~~~~~
UnitId "rts"
UnitId "ghc-prim-0.5.3"
UnitId "integer-gmp-1.0.2.0"
UnitId "base-4.12.0.0"
UnitId "array-0.5.3.0"
UnitId "deepseq-1.4.4.0"
UnitId "bytestring-0.10.8.2"
UnitId "containers-0.6.0.1"
UnitId "binary-0.8.6.0"
UnitId "text-1.2.3.1"
UnitId "transformers-0.5.6.2"
UnitId "say-0.1.0.1-9d85f3e60b43742f757835053a7ea996c1c596e4"
UnitId "cabal-test-0.1.0.0-inplace"
UnitId "cabal-test-0.1.0.0-inplace-cabal-test"
Direct deps
~~~~~~~~~~~
PkgId (PkgName "cabal-test") (Ver [0,1,0,0])
CompNameLib
base-4.12.0.0
bytestring-0.10.8.2
say-0.1.0.1
text-1.2.3.1
PkgId (PkgName "cabal-test") (Ver [0,1,0,0])
CompNameExe "cabal-test"
base-4.12.0.0
bytestring-0.10.8.2
cabal-test-0.1.0.0
# cabal-plan info --builddir ./tmp2/cabal-install.-10896/dist2/
Tree
~~~~
cabal-test-0.1.0.0
[cabal-test-0.1.0.0:exe:"cabal-test"]
├─ base-4.12.0.0
│ ├─ ghc-prim-0.5.3
│ │ └─ rts-1.0
│ ├─ integer-gmp-1.0.2.0
│ │ └─ ghc-prim-0.5.3 ┄┄
│ └─ rts-1.0 ┄┄
├─ bytestring-0.10.8.2
│ ├─ base-4.12.0.0 ┄┄
│ ├─ deepseq-1.4.4.0
│ │ ├─ array-0.5.3.0
│ │ │ └─ base-4.12.0.0 ┄┄
│ │ └─ base-4.12.0.0 ┄┄
│ ├─ ghc-prim-0.5.3 ┄┄
│ └─ integer-gmp-1.0.2.0 ┄┄
└─ cabal-test-0.1.0.0
├─ base-4.12.0.0 ┄┄
├─ bytestring-0.10.8.2 ┄┄
├─ say-0.1.0.1
│ ├─ base-4.12.0.0 ┄┄
│ ├─ bytestring-0.10.8.2 ┄┄
│ ├─ text-1.2.3.1
│ │ ├─ array-0.5.3.0 ┄┄
│ │ ├─ base-4.12.0.0 ┄┄
│ │ ├─ binary-0.8.6.0
│ │ │ ├─ array-0.5.3.0 ┄┄
│ │ │ ├─ base-4.12.0.0 ┄┄
│ │ │ ├─ bytestring-0.10.8.2 ┄┄
│ │ │ └─ containers-0.6.0.1
│ │ │ ├─ array-0.5.3.0 ┄┄
│ │ │ ├─ base-4.12.0.0 ┄┄
│ │ │ ├─ deepseq-1.4.4.0 ┄┄
│ │ │ └─ ghc-prim-0.5.3 ┄┄
│ │ ├─ bytestring-0.10.8.2 ┄┄
│ │ ├─ deepseq-1.4.4.0 ┄┄
│ │ ├─ ghc-prim-0.5.3 ┄┄
│ │ └─ integer-gmp-1.0.2.0 ┄┄
│ └─ transformers-0.5.6.2
│ └─ base-4.12.0.0 ┄┄
└─ text-1.2.3.1 ┄┄
Top-sorted
~~~~~~~~~~
UnitId "rts"
UnitId "ghc-prim-0.5.3"
UnitId "integer-gmp-1.0.2.0"
UnitId "base-4.12.0.0"
UnitId "array-0.5.3.0"
UnitId "deepseq-1.4.4.0"
UnitId "bytestring-0.10.8.2"
UnitId "containers-0.6.0.1"
UnitId "binary-0.8.6.0"
UnitId "text-1.2.3.1"
UnitId "transformers-0.5.6.2"
UnitId "say-0.1.0.1-f56dd8dcb828e676e2fe979752cedce7d5e3ea47"
UnitId "cabal-test-0.1.0.0-cfcb93c3d8595a655927c100ce79bbdaaf168f88"
UnitId "cabal-test-0.1.0.0-9848e717cfed9d05e08950e4e5de83d054a50961"
Direct deps
~~~~~~~~~~~
-
Summary: the unit id for say (
f56dd8dcb828e676e2fe979752cedce7d5e3ea47from the temp build dir is different from the other two (9d85f3e60b43742f757835053a7ea996c1c596e4). Both are installed in the store dir. -
cabal-plan diffdoes not output anything (and afaik it should at least in the first case)
# cabal-plan diff --builddir=dist-newstyle --builddir ./tmp2/cabal-install.-10896/dist2
# cabal-plan diff --builddir=./dist-newstyle --builddir=./dist2
#
Expected behavior
cabal install should only rebuild local packages like in linux
System information
- Operating system: windows 10 and 7
cabal: 3.6.2.0 but is reproduced for sure with 3.6.0.0 and 3.4.0.0 and afair with any cabal version i tried since 2.4.0.0ghcversions: 8.6.5 and 8.10.7, but probably with any
Additional context
- I decide to open a new issue as Install test executables with cabal install when "--enable-tests" present #7693 is about another different issue and cabal install run immediately after cabal build unnecessarily rebuilds the project #6919 talks about rebuild the local packages in any os
- See another reproduction case with haskell-language-server in Install test executables with cabal install when "--enable-tests" present #7693 (comment)
@fgaz @gbaz i hope there is enough info to at least demonstrate the behaviour, let me know if more info or tests are needed
Reacted by Mouse
Activity
jneira commentedon Oct 13, 2021
More info:
output of `cabal --store-dir D:\ws\haskell\cabal-test\sr install say --lib --package-env . -v3` (it installs the lib with unit id f56dd8dcb828e676e2fe979752cedce7d5e3ea47)
Output of `cabal --store-dir D:\ws\haskell\cabal-test\sr build -v3` (unit id 9d85f3e60b43742f757835053a7ea996c1c596e4)
I dont see anything on how the unit id is being computed
gbaz commentedon Oct 13, 2021
@jneira interesting! and you can confirm this is windows only? (or at least not linux?)
One thing I would suggest to investigate further is to hack up the
renderPackageHashInputsfunction, and add a trace that prints the inputs in a human readable form (as well as the resultant hash). If we're computing different hashes then clearly that should be visible when we see the inputs in human readable form, and then we can see what might cause this difference:cabal/cabal-install/src/Distribution/Client/PackageHash.hs
Line 234 in 00a2351
jneira commentedon Oct 13, 2021
no, I assumed it works in Linux from some comments in the linked issues
will try to trace the cause in the code places you are pointing, many thanks
gbaz commentedon Oct 13, 2021
I can confirm that on os x I can't reproduce.
cabal init(edit cabal file to add say as a dep)
cabal --store-dir /path/to/sr buildcabal --store-dir /path/to/sr installwill only create one installation of
sayand will reuse it.ghc 8.10.4, cabal-install 3.6.2.0
mouse07410 commentedon Oct 14, 2021
Updated
It reproduces consistently on MacOS with a pretty complex project (Agda), and with the toy project too.
ghc 9.0.1 and 8.10.7, cabal-install 3.6.2.0.
Trying to reproduce what @gbaz did, I clearly see that
say-0.1.0.1library does get rebuilt upon install:Here's
test-dr.cabal:Forcing GHC to 8.8.4 via
cabal.project- same result (rebuildssay):mouse07410 commentedon Oct 14, 2021
@jneira perhaps, editing the title of this issue to remove "windows" would make sense?
[-]`cabal install` rebuilds all dependencies after a `cabal build` in windows[/-][+]`cabal install` rebuilds all dependencies after a `cabal build` [/+]jneira commentedon Oct 14, 2021
@mouse07410 thanks for take time to reproduce it in another os, i've removed the windows label and changed the title as you noted
Interesting, we have two envs with different behaviour, so compare it could help to trace the issue. Another pieze of the puzzle which might be related is the cabal global configuration.
In one of the envs i reproduce the issue consistently such cabal config is (only non default values):
mouse07410 commentedon Oct 14, 2021
My
~/.cabal/config(many defalt values omitted to save space):jneira commentedon Oct 14, 2021
I think i've found the possible cause, thanks to @gbaz's tip
cabal-hash.txtwith the inputs used to compute the hash:cabal/cabal-install/src/Distribution/Client/ProjectBuilding.hs
Lines 1019 to 1021 in 9ef1331
store\ghc-8.6.5\say-0.1.0.1-f56dd8dcb828e676e2fe979752cedce7d5e3ea47\cabal-hash.txt(created bycabal install)store\ghc-8.6.5\say-0.1.0.1-9d85f3e60b43742f757835053a7ea996c1c596e4\cabal-hash.txt(created bycabal build)SoSocabal buildis only using the first entry forextra-lib-dirsandextra-include-dirs!!! I guess it is a bug with maybe more consequences (if it is using the first entry in other code points)cabal installis duplicating the value of bothextra-lib-dirsandextra-include-dirsseveral entriesat least one entry for those fields. I guess @gbaz hasonly one orzero entries for both, so it is not reproduced in his env. I have to say that comparing both configs made me suspect that those fields could be the cause 😉The definitive check would be remove our (@mouse07410 and mine) entries for both fields to check it make the issue go away and add one entry in the @gbaz case to check it makes reproduce the rebuild in his case.
jneira commentedon Oct 14, 2021
Possible actions to fix if we double check that is the cause:
-v, to make it more discoverable-v3using all entries for both fields normalizing them (so make it independent from separators and paths order)removing duplicate entries in thecabal installcasecabal buildis using one entry in other phases of the buildcabal installis using duplicate entries in other phases of the install (making double unnecessary work)jneira commentedon Oct 14, 2021
Oh wait the bug is cabal install is duplicating entries no cabal build pruning them 🤣 sorry for the confusion
jneira commentedon Oct 14, 2021
extra-lib-dirsandextra-include-dirsin my global cabal config:cabal installcant use relative dirs for the store. When using a existing library the error is more obscure though.extra-lib-dirsandextra-include-dirsentries does not trigger the rebuild of dependenciesMikolaj commentedon Oct 14, 2021
To clarify: you've confirmed the root cause, right?
jneira commentedon Oct 14, 2021
The cause and the bug had been reported here: #6906 🤦
But the description is not correct as the reporter found it happened inside a project using
cabal install. It does not mention the rebuild per se but duplicate entries in the store (so the same effect)jneira commentedon Oct 14, 2021
yeah, the issue i've just linked confirm it too
jneira commentedon Oct 14, 2021
So it is esentially a duplicate of #6906: "Those who cannot remember the past are condemned to repeat it."
Mikolaj commentedon Oct 14, 2021
Splendid. This seems like a very juicy and (let's hope) relatively low hanging fruit. Even just time saved diagnosing offshoots of this problems again and again is significant and could be used elsewhere.
jneira commentedon Oct 14, 2021
closing as the #6906 has more info, it is more generic (it covers repl, run, install, inside and outside a project) and has a path of action suggested by @phadej