commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.95k stars 842 forks source link

Need documents about old LTS, downgrade stack and multiple stack executables #6497

Closed chansey97 closed 4 months ago

chansey97 commented 4 months ago

Background

On GitHub, there are many old stack projects that use old LTS (before lts-12.0).

Can we seamlessly build them by the latest Stack?

It seems not.

I did some experiments and asked the question about the experiment on StackOverflow a few days ago. Unfortunately, no one answered at the moment.

The motivation is that hope to build projects using the author's original snapshot environment, because the purpose of Stack is reproducible build.

The question is that:

  1. Is it safe to downgrade Stack version?

    I found the closed issue, but it was 5 years ago.

  2. How to configure multiple Stack executables?

    For example, I want to install two stack.exe into

    C:/env/haskell/stack/v2.15.1/stack.exe
    C:/env/haskell/stack/v1.5.0/stack.exe

    For new projects, I can use PATH=C:/env/haskell/stack/v2.15.1 ; for old projects (e.g. before lts-12.0), I can use PATH=C:/env/haskell/stack/v1.5.0, but they share STACK_ROOT. Is it safe?

The key point here is: Does Stack ensure that even for different Stack versions, the database under STACK_ROOT would never corrupt? Currently, Stack docs only mentioned about upgrade but not downgrade nor multiple stack executables.

Thanks.

Stack version

Version 2.15.1

mpilgrem commented 4 months ago

@chansey97, 'never' is a high hurdle but I often find myself switching between Stack versions without lasting damage. That said, I tend to switch between the master branch version and the most recent or next most recent 'official' releases. Stack 2.15.1 still supports LTS < 12.0 (that is Cabal < 2.2, hence GHC < 8.4.1). However, if you were worried, you could always re-set STACK_ROOT when you switch Stack executables on the PATH.

EDIT: Due to a bug in Stack 2.15.1, it does not support Cabal < 2. See #6498.

mpilgrem commented 4 months ago

@chansey97, regarding your specific question about hpack-convert, I'll look at it after work, but I can't immediately see that the use of that package is limited to GHC <= 8.0.2 (LTS 8.13).

EDIT: I see the problem: hpack-convert-1.0.1 requires Glob < 0.9 and Cabal < 2.0, but neither of those bounds are reflected in its Cabal file. If those bounds are added to the Cabal file, stack init --ignore-subdirs --force uses lts-9.21 (GHC 8.0.2). The latter means that a downgrade to Stack 2.13.1 is required (if you are not using GHCup to manage versions of Stack: stack upgrade --binary-version 2.13.1). With Stack 2.13.1 and a stack.yaml:

snapshot: lts-9.21

stack build works as expected.

chansey97 commented 4 months ago

Thanks!