Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdist --pvp-bounds not working #6202

Closed
pbrisbin opened this issue Aug 4, 2023 · 5 comments
Closed

sdist --pvp-bounds not working #6202

pbrisbin opened this issue Aug 4, 2023 · 5 comments
Assignees

Comments

@pbrisbin
Copy link
Contributor

pbrisbin commented Aug 4, 2023

Steps to reproduce

% git clone https://github.com/freckle/hspec-expectations-json
% cd hspec-expectations-json
% stack sdist --pvp-bounds lower
Getting the file list for /home/patrick/code/freckle/hspec-expectations-json/.
hspec-expectations-json> List of package sources written to file
hspec-expectations-json> '/tmp/stack-sdist-c226b6c00456a0df/source-files-list'
Building a compressed archive file in the sdist format for /home/patrick/code/freckle/hspec-expectations-json/.
Wrote sdist-format compressed archive to /home/patrick/code/freckle/hspec-expectations-json/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0/hspec-expectations-json-1.0.2.0.tar.gz.
Checking package hspec-expectations-json for common mistakes.
% tar -axf .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0/hspec-expectations-json-1.0.2.0.tar.gz hspec-expectations-json-1.0.2.0/hspec-expectations-json.cabal -O | grep -A 10 'build-depends'

Expected

I expect the .cabal file to have lower bounds set, based on the in-use resolver (lts-19.0).

Actual

There are no bounds beyond those I've specifically set myself.

    build-depends:
        Diff,
        HUnit,
        aeson,
        aeson-pretty,
        base >=4.11 && <5,
        scientific,
        text,
        unordered-containers,
        vector

--
    build-depends:
        QuickCheck,
        aeson,
        aeson-qq,
        base >=4.11 && <5,
        hspec,
        hspec-expectations-json

Verbosely

% stack --verbose sdist --pvp-bounds lower
Version 2.11.1, Git revision c1167a6abc3f4978ccded5ba0246a57387da0e2f x86_64 hpack-0.35.2
2023-08-04 12:08:36.889879: [debug] Checking for project config at: /home/patrick/code/freckle/hspec-expectations-json/stack.yaml
2023-08-04 12:08:36.890157: [debug] Loading project config file stack.yaml
2023-08-04 12:08:36.895185: [debug] (SQL) SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2023-08-03 16:08:36.895158035 UTC]
2023-08-04 12:08:36.895651: [debug] Using package location completions from a lock file
2023-08-04 12:08:36.897696: [debug] Loaded snapshot from Pantry database.
2023-08-04 12:08:37.065743: [debug] Running Hpack on /home/patrick/code/freckle/hspec-expectations-json/package.yaml
2023-08-04 12:08:37.070582: [debug] Hpack output unchanged in /home/patrick/code/freckle/hspec-expectations-json/hspec-expectations-json.cabal
2023-08-04 12:08:37.070910: [debug] Prefetching git repos: []
2023-08-04 12:08:37.070943: [debug] []
2023-08-04 12:08:37.081619: [debug] Asking for a supported GHC version
2023-08-04 12:08:37.082121: [debug] Installed tools:
 - ghc-tinfo6-8.4.4
 - ghc-tinfo6-9.2.8
 - ghc-tinfo6-9.2.7
 - ghc-tinfo6-8.6.5
 - ghc-tinfo6-8.8.4
 - ghc-tinfo6-7.10.3
 - ghc-tinfo6-9.2.5
 - ghc-tinfo6-8.6.3
 - ghc-tinfo6-8.10.7
 - ghc-tinfo6-8.2.2
 - ghc-tinfo6-7.8.4
 - ghc-tinfo6-8.0.2
 - ghc-tinfo6-8.8.3
 - ghc-tinfo6-9.0.2
 - ghc-tinfo6-9.2.6
 - ghc-tinfo6-8.10.4
 - ghc-tinfo6-9.4.5
 - ghc-tinfo6-9.6.2
 - ghc-tinfo6-9.2.2
 - ghc-tinfo6-9.4.3
 - ghc-tinfo6-9.4.4
2023-08-04 12:08:37.082539: [debug] Run process: /sbin/ldconfig -p
2023-08-04 12:08:37.083472: [debug] Process finished in 1ms: /sbin/ldconfig -p
2023-08-04 12:08:37.083554: [debug] Run process: /usr/bin/ldd --version
2023-08-04 12:08:37.086391: [debug] Process finished in 3ms: /usr/bin/ldd --version
2023-08-04 12:08:37.086429: [debug] Found shared library libc6 in version: 2.37
2023-08-04 12:08:37.087443: [debug] Found shared library libtinfo.so.5 in /usr/lib/
2023-08-04 12:08:37.087506: [debug] Found shared library libtinfo.so.6 in /usr/lib/
2023-08-04 12:08:37.087535: [debug] Found shared library libncursesw.so.6 in 'ldconfig -p' output
2023-08-04 12:08:37.087565: [debug] Found shared library libgmp.so.10 in 'ldconfig -p' output
2023-08-04 12:08:37.087609: [debug] Did not find shared library libgmp.so.3
2023-08-04 12:08:37.087628: [debug] Potential GHC builds: tinfo6, standard, ncurses6
2023-08-04 12:08:37.087669: [debug] Found already installed GHC builds: tinfo6
2023-08-04 12:08:37.087790: [debug] (SQL) SELECT "id","actual_version","arch","ghc_path","ghc_size","ghc_modified","ghc_pkg_path","runghc_path","haddock_path","cabal_version","global_db","global_db_cache_size","global_db_cache_modified","info","global_dump" FROM "compiler_cache" WHERE "ghc_path"=?; [PersistText "/home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-9.0.2"]
2023-08-04 12:08:37.121140: [debug] Loaded compiler information from cache
2023-08-04 12:08:37.121241: [debug] Asking for a supported GHC version
2023-08-04 12:08:37.121273: [debug] Resolving package entries
2023-08-04 12:08:37.121310: [debug] Parsing the targets
2023-08-04 12:08:37.133566: [debug] Checking flags
2023-08-04 12:08:37.133626: [debug] SourceMap constructed
2023-08-04 12:08:37.141190: [debug] Starting to execute command inside EnvConfig
2023-08-04 12:08:37.143754: [debug] Finding out which packages are already installed
2023-08-04 12:08:37.143880: [debug] Run process: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --global --no-user-package-db dump --expand-pkgroot
2023-08-04 12:08:37.179729: [debug] Process finished in 36ms: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --global --no-user-package-db dump --expand-pkgroot
2023-08-04 12:08:37.189735: [debug] Run process: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --no-user-package-db --package-db /home/patrick/.stack/snapshots/x86_64-linux-tinfo6/03a4a750cf0f00073f9588d48b8f39b864014419839701114774d788560c97e5/9.0.2/pkgdb dump --expand-pkgroot
2023-08-04 12:08:37.210478: [debug] Process finished in 21ms: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --no-user-package-db --package-db /home/patrick/.stack/snapshots/x86_64-linux-tinfo6/03a4a750cf0f00073f9588d48b8f39b864014419839701114774d788560c97e5/9.0.2/pkgdb dump --expand-pkgroot
2023-08-04 12:08:37.210605: [debug] Run process: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --no-user-package-db --package-db /home/patrick/code/freckle/hspec-expectations-json/.stack-work/install/x86_64-linux-tinfo6/03a4a750cf0f00073f9588d48b8f39b864014419839701114774d788560c97e5/9.0.2/pkgdb dump --expand-pkgroot
2023-08-04 12:08:37.233332: [debug] Process finished in 23ms: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --no-user-package-db --package-db /home/patrick/code/freckle/hspec-expectations-json/.stack-work/install/x86_64-linux-tinfo6/03a4a750cf0f00073f9588d48b8f39b864014419839701114774d788560c97e5/9.0.2/pkgdb dump --expand-pkgroot
2023-08-04 12:08:37.233582: [info] Getting the file list for /home/patrick/code/freckle/hspec-expectations-json/.
2023-08-04 12:08:37.234397: [debug] Run process within /home/patrick/code/freckle/hspec-expectations-json/: /home/patrick/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_6HauvNHV_3.4.1.0_ghc-9.0.2 --verbose=1 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0 sdist --list-sources /tmp/stack-sdist-9e3d9f037d9fe647/source-files-list
2023-08-04 12:08:37.241815: [info] hspec-expectations-json> List of package sources written to file
2023-08-04 12:08:37.241948: [info] hspec-expectations-json> '/tmp/stack-sdist-9e3d9f037d9fe647/source-files-list'
2023-08-04 12:08:37.246284: [debug] Process finished in 12ms: /home/patrick/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_6HauvNHV_3.4.1.0_ghc-9.0.2 --verbose=1 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0 sdist --list-sources /tmp/stack-sdist-9e3d9f037d9fe647/source-files-list
2023-08-04 12:08:37.246417: [info] Building a compressed archive file in the sdist format for /home/patrick/code/freckle/hspec-expectations-json/.
2023-08-04 12:08:37.247524: [debug] Finding out which packages are already installed
2023-08-04 12:08:37.247606: [debug] Run process: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --global --no-user-package-db dump --expand-pkgroot
2023-08-04 12:08:37.292988: [debug] Process finished in 45ms: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --global --no-user-package-db dump --expand-pkgroot
2023-08-04 12:08:37.303575: [debug] Run process: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --no-user-package-db --package-db /home/patrick/.stack/snapshots/x86_64-linux-tinfo6/03a4a750cf0f00073f9588d48b8f39b864014419839701114774d788560c97e5/9.0.2/pkgdb dump --expand-pkgroot
2023-08-04 12:08:37.324811: [debug] Process finished in 21ms: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --no-user-package-db --package-db /home/patrick/.stack/snapshots/x86_64-linux-tinfo6/03a4a750cf0f00073f9588d48b8f39b864014419839701114774d788560c97e5/9.0.2/pkgdb dump --expand-pkgroot
2023-08-04 12:08:37.324939: [debug] Run process: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --no-user-package-db --package-db /home/patrick/code/freckle/hspec-expectations-json/.stack-work/install/x86_64-linux-tinfo6/03a4a750cf0f00073f9588d48b8f39b864014419839701114774d788560c97e5/9.0.2/pkgdb dump --expand-pkgroot
2023-08-04 12:08:37.347662: [debug] Process finished in 23ms: /home/patrick/.stack/programs/x86_64-linux/ghc-tinfo6-9.0.2/bin/ghc-pkg-9.0.2 --user --no-user-package-db --package-db /home/patrick/code/freckle/hspec-expectations-json/.stack-work/install/x86_64-linux-tinfo6/03a4a750cf0f00073f9588d48b8f39b864014419839701114774d788560c97e5/9.0.2/pkgdb dump --expand-pkgroot
2023-08-04 12:08:37.353757: [info] Wrote sdist-format compressed archive to /home/patrick/code/freckle/hspec-expectations-json/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.4.1.0/hspec-expectations-json-1.0.2.0.tar.gz.
2023-08-04 12:08:37.356391: [info] Checking package hspec-expectations-json for common mistakes.

Stack version

% stack --version
Version 2.11.1, Git revision c1167a6abc3f4978ccded5ba0246a57387da0e2f x86_64 hpack-0.35.2

Method of installation

https://aur.archlinux.org/packages/stack-static

Platform

Arch Linux.

@mpilgrem
Copy link
Member

mpilgrem commented Aug 4, 2023

Possibly relevant (but from November 2017): #3550.

@pbrisbin
Copy link
Contributor Author

pbrisbin commented Aug 4, 2023

Whoa, that's surprising and unfortunate. Glad to see that warning in the docs at least, but it does say:

Stack will generate a warning when a lossy conversion occurs

And I don't see any warnings in my repro above. 🤔

@mpilgrem
Copy link
Member

mpilgrem commented Aug 6, 2023

I'll see if I can understand why it does not work for lower (it works for upper). At the moment, I'm looking at at addBound in Stack.SDist.getCabalLbs.

@mpilgrem
Copy link
Member

mpilgrem commented Aug 6, 2023

I think I have found the source of the problem and its solution. I'll raise a pull request.

The source of the problem could be said to be upstream and the Cabal library. Before Cabal-3.4.0.0:

hasLowerBound anyVersion == False
anyVersion == AnyVersion

and from Cabal-3.4.0.0:

hasLowerBound anyVersion == True
anyVersion == OrLaterVersion (mkVersion [0])

but the Haddocks for Distribution.Types.VersionRange.hasLowerBound continue to state Note: this function only considers the user-specified lower bounds, but not the implicit >=0 lower bound. There is no longer any implicit >=0 lower bound, as the AnyVersion constructor of VersionRange has been removed.

@mpilgrem mpilgrem self-assigned this Aug 7, 2023
@pbrisbin
Copy link
Contributor Author

pbrisbin commented Aug 7, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants