If this is a feature rather than a bug, I'd suggest adding a corresponding hint to the list of possibleCauses in missingExeError.
stack new foocd foorm LICENSEstack buildStack builds the project.
Build fails with
foo-0.1.0.0: configure
Configuring foo-0.1.0.0...
Warning: The 'license-file' field refers to the file 'LICENSE' which does not
exist.
foo-0.1.0.0: build
Preprocessing library foo-0.1.0.0...
[1 of 1] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Lib.o )
In-place registering foo-0.1.0.0...
Preprocessing executable 'foo-exe' for foo-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/foo-exe/foo-exe-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/foo-exe/foo-exe ...
foo-0.1.0.0: copy/register
setup-Simple-Cabal-1.22.5.0-ghc-7.10.3: LICENSE: does not exist
'cabal copy' failed. Error message:
-- While building package foo-0.1.0.0 using:
/home/me/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 copy
Process exited with code: ExitFailure 1
One possible cause of this issue is:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.
$ stack --version
Version 1.1.2 x86_64 hpack-0.14.1
pacman -S stack (Arch Linux)Thanks for the report! This is IIUC a "feature", though the interface might be improvable. There are two mentions of the correct problem—are they too hidden? Should they be highlighted (as far as possible)?
I've reproduced the bug and confirmed (as I guessed) that you need to remove references to LICENSE from foo.cabal — in particular, remove the license-file: LICENSE line. I assume that's why the Cabal library fails the build and that's correct.
What could also be more helpful is
setup-Simple-Cabal-1.22.5.0-ghc-7.10.3: LICENSE: does not exist
I'd say _this_ message should be more helpful—something which is fixable through Cabal maybe (haven't inspected the code though, just triaging here)?
What is helpful, though, is this warning, which comes only too early:
Warning: The 'license-file' field refers to the file 'LICENSE' which does not
exist.
I'm a bit unhappy with mentioning this specific problem in missingExeError. But we could give
cabal check or a stack equivalent (maybe missing? See #2501), since cabal check would give a warning (which hopefully would lead to solving the problem):$ cabal check
The following warnings are likely affect your build negatively:
* The 'license-file' field refers to the file 'LICENSE' which does not exist.
Hackage would reject this package.
Thanks for the extensive reply!
The reason I was confused initially is that a missing LICENSE file is a warning with cabal build but an error with stack build. The error stems from the cabal copy command which stack build calls under the hood.
Ah, I see. I think the copy step in build is by design. It's unfortunate this leads to slightly different behavior, but rather than make this fully consistent with cabal (which we aren't), I'd guess the best would be for stack to detect this and give a clear error right away.
Does that make sense to you?
Sounds good!
I get this error on missing license file:
LICENSE: copyFile: does not exist (No such file or directory)
'cabal copy' failed. Error message:
-- While building package generics3-eot-0.1.0.0 using:
/home/flip111/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_1.24.0.0_ghc-8.0.1 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 copy
Process exited with code: ExitFailure 1
One possible cause of this issue is:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.
I was mislead by the possible cause No module "Main" and found my way here.
This happens when LICENSE is a relative path due to a multi-project repo:
- git: https://github.com/ch1bo/servant-exceptions.git
commit: 35581e940eab64f1c800c202988488f45ec29123
subdirs:
- servant-exceptions
- servant-exceptions-server
Error is
servant-exceptions > copy/register
servant-exceptions > ../LICENSE: copyFile: does not exist (No such file or directory)
Doing the equivalent of stack with cabal v2 works fine.
Most helpful comment
I get this error on missing license file: