Skip to content

ghc-pkg: cannot create: ../dist-newstyle/packagedb/ghc-7.10.3 already exists #3460

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

Closed
edsko opened this issue May 26, 2016 · 5 comments · Fixed by #3509
Closed

ghc-pkg: cannot create: ../dist-newstyle/packagedb/ghc-7.10.3 already exists #3460

edsko opened this issue May 26, 2016 · 5 comments · Fixed by #3509

Comments

@edsko
Copy link
Contributor

edsko commented May 26, 2016

I have a cabal project with one main project and two sub-cabal packages in separate directories; i.e., my cabal.project looks like

packages: ./main-package.cabal
        , ./deps/sub-package-A
        , ./deps/sub-package-B

package main-package
  tests: True

When I try to build this after wiping the dist-newstyle directory completely, I get:

[7.10.3 ~/path/to/main-package]
# cabal new-build -j
Resolving dependencies...
In order, the following will be built (use -v for more details):
sub-package-A-0.1.1.0
sub-package-B-0.1.0.0
main-package-0.1.0.0
ghc-pkg: cannot create: /home/edsko/path/to/main-package/dist-newstyle/packagedb/ghc-7.10.3 already exists

[7.10.3 ~/path/to/main-package]
# Configuring sub-package-A-0.1.1.0...

I can work around the issue by manually installing one package at a time. I suspect it's something to do with concurrency (notice the interleaving of the final message from cabal and the bash prompt above).

@ezyang note: need to pass -j to trigger parallelism.

@23Skidoo
Copy link
Member

IIRC @ezyang fixed a couple of similar issues for 1.24.

@dcoutts
Copy link
Contributor

dcoutts commented May 30, 2016

@edsko master, 1.24? Is this reliably reproducible?

@edsko
Copy link
Contributor Author

edsko commented Jun 4, 2016

1.24; I get it every time I call new-build after wiping the dist-newstyle directory in this project.

@ezyang
Copy link
Contributor

ezyang commented Jun 6, 2016

I can repro on HEAD if I pass -j. Test-case in https://github.com/ezyang/cabal/tree/T3460

ezyang added a commit to ezyang/cabal that referenced this issue Jun 6, 2016
Signed-off-by: Edward Z. Yang <[email protected]>
ezyang added a commit to ezyang/cabal that referenced this issue Jun 6, 2016
Signed-off-by: Edward Z. Yang <[email protected]>
dcoutts pushed a commit to dcoutts/cabal that referenced this issue Jun 26, 2016
dcoutts added a commit to dcoutts/cabal that referenced this issue Jun 26, 2016
Instead initialise all the ones we'll need in advance of building any
packages. The alternative would have been to use a lock, but there's no
particular advantage in trying to delay initialisation and avoiding
locks keeps things simpler.

This should fix haskell#3460

Another similar issue was fixed by 1acc00f which serialised the
registration of packages in the local inplace package db, avoiding
lost updates (which could previously be observed in test case T3460).
@dcoutts
Copy link
Contributor

dcoutts commented Jun 26, 2016

So I cannot actually reproduce the packagedb already exists behaviour with the T3460 test case (though I have seen this in the wild before too) but T3460 reveals a different issue for me in 1.24, which I actually fixed already in 1acc00f, so that's nice.

Nevertheless, it's pretty clear that it's a concurrency problem and I've made PR #3509 to avoid doing that action concurrently.

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

Successfully merging a pull request may close this issue.

4 participants