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

Stack cabal version deviates from its LTS version #3417

Closed
Tehnix opened this issue Sep 5, 2017 · 2 comments
Closed

Stack cabal version deviates from its LTS version #3417

Tehnix opened this issue Sep 5, 2017 · 2 comments

Comments

@Tehnix
Copy link

Tehnix commented Sep 5, 2017

Moving to here from DanielG/ghc-mod#905, since it seems to be more related to stack. Please read that issue for more information.

If there is any additional information I can provide, please let me know!

stack version is,

λ ~ $ stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) x86_64 hpack-0.17.1

but the issue was already present in 1.3.x.

I think it maybe can be boiled down to the dist-dir being set to cabal-2.0.0.2 even though the resolver is set to lts-9.2. This causes things like e.g. ghc-mod to get a wrong cabal version which causes it to error out as mentioned in the earlier linked issue.

E.g. nightly-2017-09-04 uses cabal-2.0.0.2 and lts-9.3 uses cabal-1.24.2.0.

λ ~ $ stack path
stack-root: /Users/tehnix/.stack
project-root: /Users/tehnix/.stack/global-project
config-location: /Users/tehnix/.stack/global-project/stack.yaml
bin-path: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2/bin:/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/tehnix/.rbenv/plugins/ruby-build/bin:/Users/tehnix/.rbenv/shims:/Users/tehnix/.rbenv/bin:/Users/tehnix/.local/bin:/usr/local/opt/pyenv/shims:/usr/local/opt/pyenv/bin:/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/Users/tehnix/.nix-profile/bin
programs: /Users/tehnix/.stack/programs/x86_64-osx
compiler-exe: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc
compiler-bin: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin
local-bin: /Users/tehnix/.local/bin
extra-include-dirs:
extra-library-dirs:
snapshot-pkg-db: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2/pkgdb
local-pkg-db: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2/pkgdb
global-pkg-db: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
ghc-package-path: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2/pkgdb:/Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2/pkgdb:/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
snapshot-install-root: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2
local-install-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2
snapshot-doc-root: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2/doc
local-doc-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2/doc
dist-dir: .stack-work/dist/x86_64-osx/Cabal-2.0.0.2
local-hpc-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2/hpc
local-bin-path: /Users/tehnix/.local/bin
ghc-paths: /Users/tehnix/.stack/programs/x86_64-osx

Replicating

  1. $ stack new Test defaulted to lts-9.3
  2. $ cd Test
  3. $ ghc-mod check src/Lib.hs
λ Haskell/Test $ ghc-mod check src/Lib.hs
Test-0.1.0.0: configure (lib + exe)
Configuring Test-0.1.0.0...
[1 of 5] Compiling CabalHelper.Types ( CabalHelper/Types.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Types.o )
[2 of 5] Compiling CabalHelper.Sandbox ( CabalHelper/Sandbox.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Sandbox.o )
[3 of 5] Compiling CabalHelper.Licenses ( CabalHelper/Licenses.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Licenses.o )

CabalHelper/Licenses.hs:56:8: error:
    • Expecting one more argument to ‘CPackageIndex ModuleName’
      Expected a type, but ‘CPackageIndex ModuleName’ has kind ‘* -> *’
    • In the type signature:
        findTransitiveDependencies :: CPackageIndex ModuleName
                                      -> Set CInstalledPackageId -> Set CInstalledPackageId
ghc-mod: readCreateProcess: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/libexec/x86_64-osx-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper "--with-ghc=/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc" "--with-ghc-pkg=/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc-pkg" "--with-cabal=cabal" "/Users/tehnix/Dropbox/__Synced/Testing/Haskell/Test" "/Users/tehnix/Dropbox/__Synced/Testing/Haskell/Test/.stack-work/dist/x86_64-osx/Cabal-2.0.0.2" "package-db-stack" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "ghc-merged-pkg-options" "ghc-lang-options" "licenses" "flags" "config-flags" "non-default-config-flags" "compiler-version" (exit 1): failed

The expectation here is of course that it does not fail compilation. Notably you can see it pulls in /Users/tehnix/Dropbox/__Synced/Testing/Haskell/Test/.stack-work/dist/x86_64-osx/Cabal-2.0.0.2, for which it automatically creates the .stack-work for. Nuking it and rerunning produces the same output.

@Tehnix
Copy link
Author

Tehnix commented Sep 5, 2017

Okay, beats me who it got there, but I see a Cabal-2.0.0.2-1HTE9d8rwAi7gJIdEHeKh7.conf in my ~/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d,

λ ghc-8.0.2/package.conf.d $ ls
Cabal-1.24.2.0.conf                       haskeline-0.7.3.0.conf
Cabal-2.0.0.2-1HTE9d8rwAi7gJIdEHeKh7.conf hoopl-3.10.2.1.conf
array-0.5.1.1.conf                        hpc-0.6.0.3.conf
base-4.9.1.0.conf                         integer-gmp-1.0.0.1.conf
binary-0.8.3.0.conf                       package.cache
bytestring-0.10.8.1.conf                  pretty-1.1.3.3.conf
containers-0.5.7.1.conf                   process-1.4.3.0.conf
deepseq-1.4.2.0.conf                      rts.conf
directory-1.3.0.0.conf                    template-haskell-2.11.1.0.conf
filepath-1.4.1.1.conf                     terminfo-0.4.0.2.conf
ghc-8.0.2.conf                            time-1.6.0.1.conf
ghc-boot-8.0.2.conf                       transformers-0.5.2.0.conf
ghc-boot-th-8.0.2.conf                    unix-2.7.2.1.conf
ghc-prim-0.5.0.0.conf                     xhtml-3000.2.1.conf
ghci-8.0.2.conf

I deleted Cabal-2.0.0.2-1HTE9d8rwAi7gJIdEHeKh7.conf from the folder (after backing it up), and now I get Cabal-1.24.2.0 when running stack path,

λ ~ $ stack path
stack-root: /Users/tehnix/.stack
project-root: /Users/tehnix/.stack/global-project
config-location: /Users/tehnix/.stack/global-project/stack.yaml
bin-path: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2/bin:/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/tehnix/.rbenv/plugins/ruby-build/bin:/Users/tehnix/.rbenv/shims:/Users/tehnix/.rbenv/bin:/Users/tehnix/.local/bin:/usr/local/opt/pyenv/shims:/usr/local/opt/pyenv/bin:/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/Users/tehnix/.nix-profile/bin
programs: /Users/tehnix/.stack/programs/x86_64-osx
compiler-exe: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc
compiler-bin: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin
local-bin: /Users/tehnix/.local/bin
extra-include-dirs:
extra-library-dirs:
snapshot-pkg-db: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2/pkgdb
local-pkg-db: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2/pkgdb
global-pkg-db: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
ghc-package-path: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2/pkgdb:/Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2/pkgdb:/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
snapshot-install-root: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2
local-install-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2
snapshot-doc-root: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.2/8.0.2/doc
local-doc-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2/doc
dist-dir: .stack-work/dist/x86_64-osx/Cabal-1.24.2.0
local-hpc-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.2/8.0.2/hpc
local-bin-path: /Users/tehnix/.local/bin
ghc-paths: /Users/tehnix/.stack/programs/x86_64-osx

ghc-mod now works, since it's getting the corresponding cabal version for the LTS. In short, the fix was to delete ~/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d/Cabal-2.0.0.2-1HTE9d8rwAi7gJIdEHeKh7.conf.

Could it possibly be that some extra package or something in a stack.yaml caused a Cabal-2.0.0.2 to download, and then since it was a later version of cabal, stack would automatically pick this one up instead?

@mgsloan
Copy link
Contributor

mgsloan commented Sep 18, 2017

The cabal version used by stack is not the one specified by resolver. To me this behavior is also counter-intuitive. There is a discussion of this here, closing this as a dupe of that, if I understand correctly.

@mgsloan mgsloan closed this as completed Sep 18, 2017
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