Suppose I'd like to build an old stack project from GitHub (which uses snapshot before lts-12.0), can I build it with latest stack? I did some experiments as follows.
For example, hpack-convert uses lts-8.13, when I build it with Stack 2.15.1, which is latest version at the moment, it complains:
Warning: The package-indices key is deprecated in favour of package-index.
Warning: The package-indices key is deprecated in favour of package-index.
Error: [S-305]
Failed to generate a Cabal file using the Hpack library on file:
E:\work-pl\haskell\code\hpack-convert\hpack-convert-1.0.1\package.yaml. The error encountered was:
E:\work-pl\haskell\code\hpack-convert\hpack-convert-1.0.1\package.yaml: Error while parsing $.library.dependencies - expected Array, Object, or String, but encountered Null
I seems that there some format incompatible in stack.yaml
and package.yaml
.
I fixed these errors and stack build
again.
Stack started downloading ghc-8.0.2, but still got an error afterwards.
E:\work-pl\haskell\code\hpack-convert\hpack-convert-1.0.1>stack build
Warning: The package-indices key is deprecated in favour of package-index.
Preparing to install GHC to an isolated location. This will not interfere with any system-level installation.
Downloaded ghc-8.0.2.
Already downloaded 7z.dll.
Already downloaded 7z.exe.
Decompressing ghc-8.0.2.tar.xz...
7-Zip 22.01 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15
Scanning the drive for archives:
1 file, 152282428 bytes (146 MiB)
Extracting archive: C:\Users\Chansey\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz
--
Path = C:\Users\Chansey\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2.tar.xz
Type = xz
Physical Size = 152282428
Method = LZMA2:23 CRC64
Streams = 1
Blocks = 1
Everything is Ok
Size: 1435248640
Compressed: 152282428
Extracting ghc-8.0.2.tar...
Extracted total of 21 files from ghc-8.0.2.tar
GHC installed to C:\Users\Chansey\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\.
Warning: Stack's support of Cabal versions below 2.2.0.0 is deprecated and may be removed from the next version of Stack. Cabal version 1.24.2.0 was found. Consider using a resolver that is
lts-12.0 or later or nightly-2018-03-13 or later.
ghc.exe: unrecognised flag: -no-keep-hi-files
did you mean one of:
-keep-hc-files
unrecognised flag: -no-keep-o-files
did you mean one of:
-keep-s-files
Usage: For basic information, try the `--help' option.
Warning: The package-indices key is deprecated in favour of package-index.
Error: [S-6374]
While building simple Setup.hs (scroll up to its section to see the error) using:
C:\Users\Chansey\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.2\bin\ghc-8.0.2.exe -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-1.24.2.0 C:\Users\Chansey\AppData\Roaming\stack\setup-exe-src\setup-9p6GVs8J.hs C:\Users\Chansey\AppData\Roaming\stack\setup-exe-src\setup-shim-9p6GVs8J.hs -o C:\Users\Chansey\AppData\Roaming\stack\setup-exe-cache\x86_64-windows\tmp-Cabal-simple_9p6GVs8J_1.24.2.0
_ghc-8.0.2.exe -no-keep-hi-files -no-keep-o-files
Process exited with code: ExitFailure 1
Notice that
Warning: Stack's support of Cabal versions below 2.2.0.0 is deprecated and may be removed from the next version of Stack. Cabal version 1.24.2.0 was found. Consider using a resolver that is lts-12.0 or later or nightly-2018-03-13 or later.
It seems that the latest stack doesn't support old snapshot (before lts-12.0 or nightly-2018-03-13) ?
There are two ways to fix this problem.
Reset stack.yaml to use more newer snapshot (e.g. using stack init
) and fix possible build errors due to cabal deps.
Downgrade the stack version, so that I can use the package author’s original snapshot environment.
I have successfully solve this problem via the 1st approach, but the question here is that:
If I'd like to use the 2nd approach (i.e. downgrade the stack version), for example, download old stack binary and replace the latest version, is it safe? (I did't try because I'm afraid this would break my stack environment.)
Thanks.
P.S. Stack docs only mentioned about upgrade but not downgrade.
Stack's support of Cabal < 2.2 is deprecated in Stack 2.15.1, but Stack 2.15.1 was intended to still support Cabal-1.24.2.0. However, a change was made in Stack 2.15.1 - ironically, to avoid a bug in GHC 8.0.1 and 8.0.2 - that made use of GHC's flags -no-keep-hi-files
and -no-keep-o-files
- and those flags were introduced with GHC 8.2.1. So, in practice, inadvertently, Stack 2.15.1 does not support GHC < 8.2.1.
You should be able to downgrade from Stack 2.15.1 to 2.13.1 without ill effects.