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

copy command fails when building only some components #2780

Closed
snoyberg opened this issue Aug 18, 2015 · 16 comments
Closed

copy command fails when building only some components #2780

snoyberg opened this issue Aug 18, 2015 · 16 comments

Comments

@snoyberg
Copy link
Collaborator

Actions:

  1. Create a project with both a library and executable
  2. cabal clean
  3. cabal configure
  4. cabal build lib:packagename
  5. cabal copy

Expected: command succeeds, copying over the library only, and not the test suite

Actual: errors out since the executable does not exist, e.g.:

Installing library in
/home/vagrant/.cabal/lib/x86_64-linux-ghc-7.10.2/tmp-0.1.0.0-JdaAODhQa7p5WhxMngbYYt
Installing executable(s) in /home/vagrant/.cabal/bin
Setup.hs: dist/build/tmp-exe/tmp-exe: does not exist

This problem could be mitigated by allowing copy to take a list of components like build does.

@lukehoersten
Copy link
Member

+1

@mgsloan
Copy link
Collaborator

mgsloan commented Nov 10, 2015

Recently ran into this one... +1

mgsloan added a commit to commercialhaskell/stack that referenced this issue Nov 10, 2015
ezyang added a commit to ezyang/cabal that referenced this issue Jan 19, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Jan 19, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Jan 19, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Jan 27, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Jan 28, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Feb 2, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Feb 2, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Feb 2, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Feb 2, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Feb 6, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Feb 20, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Feb 20, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Mar 5, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Mar 16, 2016
ezyang added a commit to ezyang/cabal that referenced this issue Mar 16, 2016
@mgsloan
Copy link
Collaborator

mgsloan commented Aug 13, 2016

@ezyang Ahh, I didn't realize that exe-name was a valid cabal build target. Thanks!

You seem to be assuming that there is a way to configure a set of packages to install in 1.24! Did you mean to copy whatever what was last built? I suppose that is possible, but this would imply ./Setup build somehow saves the set of arguments it was called with, which copy then takes. Isn't just specifying it explicitly better?

Sorry, maybe I am massively misunderstanding the question.

True, I meant the build step. Yeah, explicit is probably better for the Cabal layer.

Backporting this to 1.24 looks non-trivial, so I'm inclined to leave it be.

Would you be inclined to merge if I implemented a new fix atop 1.24? The alternative is going to be to move more and more Cabal functionality into stack / Setup.hs hacks.

@ezyang
Copy link
Contributor

ezyang commented Aug 13, 2016

Surely it can't be that hard to backport. The main thing is I refactored Install to operate on a per-CLBI basis prior to this patch; you'd have to also bring in those changes as well.

@23Skidoo
Copy link
Member

23Skidoo commented Aug 13, 2016

Looking at #3022 (which is the version that got merged), I see that the patch in question (f88f502 ) is number 25 in a series that includes 2040c1c among other things. This makes me somewhat uncomfortable with the amount of changes required in the supposedly stable branch.

@mgsloan

Would you be inclined to merge if I implemented a new fix atop 1.24?

Sure, if you or @ezyang are willing to do the actual work, I'll reconsider.

@23Skidoo
Copy link
Member

@mgsloan

So people are asking for a new 1.24 release, should I wait for your patch or remilestone this ticket for Cabal 1.24.0.2?

@mgsloan
Copy link
Collaborator

mgsloan commented Aug 22, 2016

Feel free to make the release. I'll take a look and may have a patch ready soon

@23Skidoo
Copy link
Member

@mgsloan Thanks!

@ezyang ezyang modified the milestones: Later, Cabal-1.24.0.2 Sep 6, 2016
@ezyang
Copy link
Contributor

ezyang commented Oct 25, 2016

@mgsloan GHC 8.0.2 is coming soon, so this is your last chance to get a 1.24 patch in!

@23Skidoo
Copy link
Member

@mgsloan @ezyang Guys, is this still broken or is the ticket only open because the fix is not in 1.24? If it's the latter, I think we should close it.

@snoyberg
Copy link
Collaborator Author

The problem still exists with Cabal 2.0:

$ stack --resolver ghc-8.2.1 exec --no-ghc-package-path -- runghc Setup.hs configure --user
Configuring foo-0.1.0.0...
$ stack --resolver ghc-8.2.1 exec --no-ghc-package-path -- runghc Setup.hs build lib:foo
Preprocessing library for foo-0.1.0.0..
Building library for foo-0.1.0.0..
[1 of 1] Compiling Lib              ( src/Lib.hs, dist/build/Lib.o )
$ stack --resolver ghc-8.2.1 exec --no-ghc-package-path -- runghc Setup.hs copy
Installing library in /Users/michael/.cabal/lib/x86_64-osx-ghc-8.2.1/foo-0.1.0.0-wI4nsLkf3p3YT1pJBa9gp
Installing executable foo-exe in /Users/michael/.cabal/bin
Warning: The directory /Users/michael/.cabal/bin is not in the system search
path.
dist/build/foo-exe/foo-exe: copyFile: does not exist (No such file or directory)

I understand that Cabal 2.0 has introduced per-component configuration, which is intended as a workaround. I've discussed with @ezyang, and the ultimate plan is to add support for this to Stack (which will be necessary for Backpack anyway). In the meanwhile, we have a workaround in Stack that forces the executable component to be built the first time.

So my take: I still consider this a bug that is unfixed in Cabal 2.0, but we're effectively working around it in Stack.

@23Skidoo
Copy link
Member

@snoyberg Thanks!

@ezyang
Copy link
Contributor

ezyang commented Dec 29, 2017

Sorry I missed the conversation here. Let me clarify a few points:

  • Per-component build will solve the problem, as @snoyberg says
  • ./Setup build someexe && ./Setup copy indeed does not work in Cabal HEAD (and it will never work, for reasons explicated earlier in this ticket; specifically, Cabal would need to start tracking state of "what the most recent set of executables that were built" where, and this just doesn't seem like a good answer when there's a better solution below)
  • ./Setup build someexe && ./Setup copy someexe (@snoyberg suggested alleviation at the very beginning of this ticket) works in Cabal 2.0, and it may be worth adding the little bit of logic to support it

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.

6 participants