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

Setup.hs cannot use local snapshot dependencies WAS stack failing to resolve local dependencies of multiple package project #897

Closed
mitchellwrosen opened this issue Sep 2, 2015 · 19 comments

Comments

@mitchellwrosen
Copy link
Contributor

Hi, I can't seem to reproduce this with a smaller example repo so I'll just point to the one that's failing: https://github.com/mitchellwrosen/cabal-macosx/tree/b6e5f714fbf451a72c8b7e70577ce7d9e342f8d0

I'm trying to stackify this three year old repo, and the example projects, which depend on the cabal-macosx, fail to build:

--  While building package gtkHello-0.1.0 using:
      /Users/mrosen/.stack/programs/x86_64-osx/ghc-7.10.2/bin/runhaskell -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ /Users/mrosen/haskell/cabal-macosx/examples/gtkHello/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/ configure --user --package-db=clear --package-db=global --package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --package-db=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --dependency=base=base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f --dependency=cabal-macosx=cabal-macosx-0.2.2-2b48f42cc1cff87ee217afa95d34d3ed --dependency=gtk=gtk-0.13.9-37993e343fdd10dc6c30b07beea3d344 --libdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/lib --bindir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/bin --datadir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/share --docdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0 --htmldir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0 --haddockdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/mrosen/haskell/cabal-macosx/.stack-work/logs/gtkHello-0.1.0.log


    /Users/mrosen/haskell/cabal-macosx/examples/gtkHello/Setup.hs:3:8:
        Could not find module ‘Distribution.MacOSX’
        Perhaps you meant
          Distribution.Make (from Cabal-1.22.4.0@Cabal_96aI7pZyaxU3dsgngOxbdK)
          Distribution.GetOpt
          Distribution.Package (from Cabal-1.22.4.0@Cabal_96aI7pZyaxU3dsgngOxbdK)
        Use -v to see a list of the files searched for.

I'm not really sure why; stack exec ghc-pkg list shows cabal-macosx-0.2.2 in .stack-work/install/x86_64-osx/lts-3.3/7.10.2/pkgdb, and stack exec ghc-pkg describe cabal-macosx lists Distribution.MacOSX as an exposed module. And as I said, I couldn't replicate this with a simpler multiple-package example.

Here's the entire stack -v build in case any of it is relevant:

Version 0.1.3.1
2015-09-02 04:53:55.87362: [debug] Checking for project config at: /Users/mrosen/haskell/cabal-macosx/stack.yaml @(stack-0.1.3.1:Stack.Config src/Stack/Config.hs:459:9)
2015-09-02 04:53:55.873842: [debug] Loading project config file stack.yaml @(stack-0.1.3.1:Stack.Config src/Stack/Config.hs:482:13)
2015-09-02 04:53:55.883887: [debug] Run process: ghc --info @(stack-0.1.3.1:System.Process.Read src/System/Process/Read.hs:255:3)
2015-09-02 04:53:55.937986: [debug] Run process: ghc --numeric-version @(stack-0.1.3.1:System.Process.Read src/System/Process/Read.hs:255:3)
2015-09-02 04:53:55.965839: [debug] Run process: ghc-pkg --no-user-package-db field --simple-output Cabal id @(stack-0.1.3.1:System.Process.Read src/System/Process/Read.hs:255:3)
2015-09-02 04:53:55.986855: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack-0.1.3.1:System.Process.Read src/System/Process/Read.hs:255:3)
2015-09-02 04:53:56.009977: [debug] Checking resolver: lts-3.3 @(stack-0.1.3.1:Stack.Build.Source src/Stack/Build/Source.hs:76:13)
2015-09-02 04:53:56.215766: [warn] Warning: modules not listed in cabal-macosx.cabal for 'macosx-app' component (add to other-modules):
    Distribution.MacOSX
    Distribution.MacOSX.AppBuildInfo
    Distribution.MacOSX.Common
    Distribution.MacOSX.DG
    Distribution.MacOSX.Dependencies @(stack-0.1.3.1:Stack.Package src/Stack/Package.hs:647:11)
2015-09-02 04:53:56.21763: [debug] Run process: ghc-pkg --global --no-user-package-db dump --expand-pkgroot @(stack-0.1.3.1:System.Process.Read src/System/Process/Read.hs:255:3)
2015-09-02 04:53:56.248176: [debug] Run process: ghc-pkg --user --no-user-package-db --package-db /Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ dump --expand-pkgroot @(stack-0.1.3.1:System.Process.Read src/System/Process/Read.hs:255:3)
2015-09-02 04:53:56.360577: [debug] Run process: ghc-pkg --user --no-user-package-db --package-db /Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/pkgdb/ dump --expand-pkgroot @(stack-0.1.3.1:System.Process.Read src/System/Process/Read.hs:255:3)
2015-09-02 04:53:56.73411: [debug] All installs are local; releasing snapshot lock early. @(stack-0.1.3.1:Stack.Build src/Stack/Build.hs:92:28)
2015-09-02 04:53:56.734519: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack-0.1.3.1:System.Process.Read src/System/Process/Read.hs:255:3)
2015-09-02 04:53:56.757883: [info] gtkHello-0.1.0: configure @(stack-0.1.3.1:Stack.Build.Execute src/Stack/Build/Execute.hs:505:18)
2015-09-02 04:53:56.758061: [debug] Run process: /Users/mrosen/.stack/programs/x86_64-osx/ghc-7.10.2/bin/runhaskell -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ /Users/mrosen/haskell/cabal-macosx/examples/gtkHello/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/ configure --user --package-db=clear --package-db=global --package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --package-db=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --dependency=base=base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f --dependency=cabal-macosx=cabal-macosx-0.2.2-2b48f42cc1cff87ee217afa95d34d3ed --dependency=gtk=gtk-0.13.9-37993e343fdd10dc6c30b07beea3d344 --libdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/lib --bindir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/bin --datadir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/share --docdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0 --htmldir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0 --haddockdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0 @(stack-0.1.3.1:Stack.Build.Execute src/Stack/Build/Execute.hs:611:13)
2015-09-02 04:53:56.94405: [info] wxHello-0.1.0: configure @(stack-0.1.3.1:Stack.Build.Execute src/Stack/Build/Execute.hs:505:18)
2015-09-02 04:53:56.944259: [debug] Run process: /Users/mrosen/.stack/programs/x86_64-osx/ghc-7.10.2/bin/runhaskell -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ /Users/mrosen/haskell/cabal-macosx/examples/wxHello/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/ configure --user --package-db=clear --package-db=global --package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --package-db=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --dependency=base=base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f --dependency=cabal-macosx=cabal-macosx-0.2.2-2b48f42cc1cff87ee217afa95d34d3ed --dependency=wx=wx-0.92.0.0-4fb8738e2e82f261b6019b277a7473cf --libdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/lib --bindir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/bin --datadir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/share --docdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/wxHello-0.1.0 --htmldir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/wxHello-0.1.0 --haddockdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/wxHello-0.1.0 @(stack-0.1.3.1:Stack.Build.Execute src/Stack/Build/Execute.hs:611:13)
Completed all 2 actions.

--  While building package wxHello-0.1.0 using:
      /Users/mrosen/.stack/programs/x86_64-osx/ghc-7.10.2/bin/runhaskell -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ /Users/mrosen/haskell/cabal-macosx/examples/wxHello/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/ configure --user --package-db=clear --package-db=global --package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --package-db=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --dependency=base=base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f --dependency=cabal-macosx=cabal-macosx-0.2.2-2b48f42cc1cff87ee217afa95d34d3ed --dependency=wx=wx-0.92.0.0-4fb8738e2e82f261b6019b277a7473cf --libdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/lib --bindir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/bin --datadir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/share --docdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/wxHello-0.1.0 --htmldir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/wxHello-0.1.0 --haddockdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/wxHello-0.1.0
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/mrosen/haskell/cabal-macosx/.stack-work/logs/wxHello-0.1.0.log


    /Users/mrosen/haskell/cabal-macosx/examples/wxHello/Setup.hs:3:8:
        Could not find module ‘Distribution.MacOSX’
        Perhaps you meant
          Distribution.Make (from Cabal-1.22.4.0@Cabal_96aI7pZyaxU3dsgngOxbdK)
          Distribution.GetOpt
          Distribution.Package (from Cabal-1.22.4.0@Cabal_96aI7pZyaxU3dsgngOxbdK)
        Use -v to see a list of the files searched for.


--  While building package gtkHello-0.1.0 using:
      /Users/mrosen/.stack/programs/x86_64-osx/ghc-7.10.2/bin/runhaskell -package=Cabal-1.22.4.0 -clear-package-db -global-package-db -package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ /Users/mrosen/haskell/cabal-macosx/examples/gtkHello/Setup.hs --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/ configure --user --package-db=clear --package-db=global --package-db=/Users/mrosen/.stack/snapshots/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --package-db=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/pkgdb/ --dependency=base=base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f --dependency=cabal-macosx=cabal-macosx-0.2.2-2b48f42cc1cff87ee217afa95d34d3ed --dependency=gtk=gtk-0.13.9-37993e343fdd10dc6c30b07beea3d344 --libdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/lib --bindir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/bin --datadir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/share --docdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0 --htmldir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0 --haddockdir=/Users/mrosen/haskell/cabal-macosx/.stack-work/install/x86_64-osx/lts-3.3/7.10.2/doc/gtkHello-0.1.0
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/mrosen/haskell/cabal-macosx/.stack-work/logs/gtkHello-0.1.0.log


    /Users/mrosen/haskell/cabal-macosx/examples/gtkHello/Setup.hs:3:8:
        Could not find module ‘Distribution.MacOSX’
        Perhaps you meant
          Distribution.Make (from Cabal-1.22.4.0@Cabal_96aI7pZyaxU3dsgngOxbdK)
          Distribution.GetOpt
          Distribution.Package (from Cabal-1.22.4.0@Cabal_96aI7pZyaxU3dsgngOxbdK)
        Use -v to see a list of the files searched for.
@snoyberg
Copy link
Contributor

snoyberg commented Sep 2, 2015

The reason this is happening is that, currently, we only allow the Setup.hs file to use global and snapshot packages, not local packages. The reason is reproducible builds: relying on something in the local database means that a build today may fail later if the local database is in a different state.

I'm open to relaxing this. There's even a comment about all of this in the codebase at: https://github.com/commercialhaskell/stack/blob/master/src/Stack/Build/Execute.hs#L678.

I think the best course of action here is to add bcoLocalDB when compiling a local package. You interested in taking a stab at making that change and see if it solves your problem?

@mitchellwrosen
Copy link
Contributor Author

I'm not sure I understand. This repo has two packages, the second of which depends on the first in its Setup.hs, and it builds successfully: https://github.com/mitchellwrosen/stack-897-example

@snoyberg
Copy link
Contributor

snoyberg commented Sep 2, 2015

That's because you've set build-type: Simple at https://github.com/mitchellwrosen/stack-897-example/blob/master/child/child.cabal#L12, which means "ignore the Setup.hs file and just use a simple build plan." Changing that to build-type: Custom should demonstrate the problem.

@mitchellwrosen
Copy link
Contributor Author

I see. Sure, I can attempt that change but it might take a bit =)

@snoyberg
Copy link
Contributor

snoyberg commented Sep 2, 2015

If you get stuck, let me know. Initial version would just be adding "-package-db=" ++ toFilePath (bcoLocalDB eeBaseConfigOpts) and confirming that it fixes your problem.

@mitchellwrosen
Copy link
Contributor Author

Well, that was simple enough, and it did fix the problem. So, bigger picture, I don't really have a strong opinion about which package databases Setup.hs has. The comment in the source code about -hide-all-packages and explicitly listing packages seems reasonable.

@snoyberg
Copy link
Contributor

snoyberg commented Sep 2, 2015

You interested in taking a crack at implementing that? I don't foresee any obstacles, especially since the list of available dependencies is already populated at this point in the build process.

@mitchellwrosen
Copy link
Contributor Author

Sure. Where is the list of available dependencies? =)

@snoyberg
Copy link
Contributor

snoyberg commented Sep 2, 2015

Just walked out of the house so I can't show you the exact code. Look in
the getConfigCache. You should be able to refactor to have access to the
ConfigCache

On Wed, Sep 2, 2015, 8:51 AM Mitchell Rosen notifications@github.com
wrote:

Sure. Where is the list of available dependencies? =)


Reply to this email directly or view it on GitHub
#897 (comment)
.

mitchellwrosen added a commit to mitchellwrosen/stack that referenced this issue Sep 2, 2015
@mitchellwrosen
Copy link
Contributor Author

Ok, here's a first attempt: #899

@mgsloan
Copy link
Contributor

mgsloan commented Sep 3, 2015

A couple days ago, Duncan mentioned that cabal plans to have build dependencies for Setup.hs, like this: haskell/cabal#948

For now, it does seem like a reasonable idea to use the same set of packages as the package itself + Cabal.

@snoyberg snoyberg changed the title stack failing to resolve local dependencies of multiple package project Setup.hs cannot use local snapshot dependencies WAS stack failing to resolve local dependencies of multiple package project Sep 6, 2015
@snoyberg snoyberg added this to the 0.3.0.0 milestone Sep 6, 2015
mitchellwrosen added a commit to mitchellwrosen/stack that referenced this issue Sep 6, 2015
snoyberg added a commit that referenced this issue Sep 7, 2015
Give Setup.hs all project dependencies #897
@snoyberg
Copy link
Contributor

snoyberg commented Sep 7, 2015

This resulted in a regression (#941), but let's follow up on that in the other issue. I'm going to close this as resolved due to #897.

@asr
Copy link

asr commented Sep 19, 2016

I'm going to close this as resolved due to #897.

I guess you meant #899.

@snoyberg
Copy link
Contributor

So it would seem. Blast from the past :)

@asr
Copy link

asr commented Sep 19, 2016

The present for me :-)
See Error installing the suffle library with stack.

@snoyberg
Copy link
Contributor

What happens if you manually install the dependencies with stack build uuagc-cabal ... first?

On Mon, Sep 19, 2016 at 8:03 PM, Andrés Sicard-Ramírez <
notifications@github.com> wrote:

The present for me :-)
See Error installing the suffle library with stack
http://stackoverflow.com/questions/39564607/error-installing-the-suffle-library-with-stack
.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#897 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADBBwYYt3Sxv-XrZaIlPAjjEYFdq-7Pks5qrsBIgaJpZM4F2QHO
.

@asr
Copy link

asr commented Sep 19, 2016

After installing uuagc-cabal in the shuffle directory I got the same error.

@snoyberg
Copy link
Contributor

I've added an answer at: http://stackoverflow.com/a/39579714/369198

@asr
Copy link

asr commented Sep 19, 2016

Your answer above fixed the problem. Thanks!

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

No branches or pull requests

4 participants