Looks like the setup-config is located in a slightly different location when building with cabal-2.4.1.0:
$ /Users/jky/wrk/haskell-works/haskell-ide-engine-6/.stack-work/install/x86_64-osx/lts-12.14/8.4.3/bin/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "v1-style" "/Users/jky/wrk/haskell-works/hw-json" "/Users/jky/wrk/haskell-works/hw-json/dist-newstyle/build/x86_64-osx/ghc-8.4.3/hw-json-0.9.0.1" "package-db-stack" "flags" "compiler-version" "ghc-merged-pkg-options" "config-flags" "non-default-config-flags" "ghc-src-options" "ghc-pkg-options" "ghc-lang-options" "ghc-options" "source-dirs" "entrypoints" "needs-build-output"
cabal-helper-wrapper: /Users/jky/wrk/haskell-works/hw-json/dist-newstyle/build/x86_64-osx/ghc-8.4.3/hw-json-0.9.0.1/setup-config: openFile: does not exist (No such file or directory)
$ find dist-newstyle -name setup-config
dist-newstyle/build/x86_64-osx/ghc-8.4.3/hw-json-0.9.0.1/t/hw-json-test/opt/setup-config
dist-newstyle/build/x86_64-osx/ghc-8.4.3/hw-json-0.9.0.1/opt/setup-config
Notice that haskell-ide-engine expects the file to be located here:
dist-newstyle/build/x86_64-osx/ghc-8.4.3/hw-json-0.9.0.1/setup-config
but it is actually found here:
dist-newstyle/build/x86_64-osx/ghc-8.4.3/hw-json-0.9.0.1/opt/setup-config
It is unclear if it is the cabal version that is causing this difference or if it is the cabal file version, which I've specified like this:
$ head -n 1 hw-json.cabal
cabal-version: 2.2
After downgrading my cabal file to remove cabal-version: 2.2 and add cabal-version: >= 1.10, the problem still persists.
Work around:
$ cd dist-newstyle/build/x86_64-osx/ghc-8.4.3/hw-json-0.9.0.1/
$ ln -s opt/setup-config setup-config
Work around in the general case:
# haskell-ide-engine work-around
for x in $(find dist-newstyle -name setup-config | grep '/opt/setup-config$' | sed 's|/opt/setup-config$||g'); do
( cd $x
ln -fs opt/setup-config setup-config
)
done
@newhoggy this is a problem with new-build in general, and the interim support we have at the moment, which basically only supports the library component.
Reading setup-config seems to be unreliable anyway because producing it requires new-build to be executed first. Even new-configure doesn't seem to be enough.
One of the implications is that changing the version number in a .cabal file changes the path to the file which doesn't exist until new-build is issued so the IDE reports readCreateProcess errors.
Which is not an ideal user experience.
Can it be worked around without requiring setup-config to be there?
I am curious, should we be using v2-style instead in the cabal helper?
Since dist-newstyle/cache/plan.json is in an "easier" location and it is generated by cabal new-configure we could use it, and issue cabal new-configure automatically when it is not present?
I wanted to try, but I see that to v2-style I should provide something that is called Unit, which is, perhaps, looks something like <my-executable-name>-<version>-inplace and this is where I am a bit lost. Which one do I suppose to use? How do I determine the "right" executable name, assuming that there can be >1 of them in the cabal file?
Can anyone provide a direction here?
@AlexeyRaga , the proper new-build support is coming via https://github.com/alanz/haskell-ide-engine/tree/bleeding-edge-c-h
It sort of works at the moment, but has issues with caching, and detecting changes in the project being developed.
@alanz awesome, thanks! :) Can't wait! :)
Any news? I'm eagerly awaiting this! :)
@DanielG has managed to find some time to work on this solidly in the next few months, so rather than doing my band-aid patch, we will wait for his work.
And we are hoping for some assistance from @power-fungus and @fendor too.
@alanz Can we document in the README that executable support is currently not working and users should work with library stanzas instead?
We can do that.
@masaeedu is it possible to use the library stanza yet compile to an executable?
@newhoggy I created a link of setup-config under /dist-newstyle/build/x86_64-linux/ghc-8.6.5/app-0.1.0.0 and when I launch Atom I still receive error:
readCreateProcess: /nix/store/jq8x50rkl3cm7cqkj1zsk6kfbb692iwv-cabal-helper-0.9.0.0/bin/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "v1-style" "/home/neo/Sources/miso/sample-app" "/home/neo/Sources/miso/sample-app/dist-newstyle/build/x86_64-linux/ghc-8.6.5/app-0.1.0.0" "package-db-stack" "flags" "compiler-version" "ghc-merged-pkg-options" "config-flags" "non-default-config-flags" "ghc-src-options" "ghc-pkg-options" "ghc-lang-options" "ghc-options" "source-dirs" "entrypoints" "needs-build-output" (exit 1): failed
Also, why is the command above from HIE calling v1-style when I only have a dist-newstyle folder and a cabal.project?
Because HIE can only handle cabal v1-projects at the moment. Support for cabal v2 is coming via #1126
is it possible to use the library stanza yet compile to an executable?
Afaik it is not.
I created a link of setup-config under /dist-newstyle/build/x86_64-linux/ghc-8.6.5/app-0.1.0.0 and when I launch Atom I still receive error
Could you run the command in a shell to try to get a more informative error?
Because HIE can only handle cabal v1-projects at the moment. Support for cabal v2 is coming via #1126
Well, i would add "... in a reliable way for most environments" to that.
In my case i've got to use haskell-ide-engine with a simple cabal based project built with v2-build for both the executable and library, without any hard link:
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
%USERPROFILE%\Local settings\Cache\cabal-helper cabal v2-clean && cabal v2-configure in the projectcabal-3.0.0.0 using stack install.hs cabal-hie-8.6.5)cabal-helper call:D:\csd\ghc-8.6.5\cabal-helper-0.9.0.0-968d5c7983449350a92033da9a1c8934178545ff\bin\cabal-helper-wrapper.exe "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "v1-style" "D:\ws\haskell\cabal-test" "D:\ws\haskell\cabal-test\dist-newstyle/build\x86_64-windows\ghc-8.6.5\cabal-test-0.1.0.0" "package-db-stack" "flags" "compiler-version" "ghc-merged-pkg-options" "config-flags" "non-default-config-flags" "ghc-src-options" "ghc-pkg-options" "ghc-lang-options" "ghc-options" "source-dirs" "entrypoints" "needs-build-output"
v1-style option although it is able to handle the project built with v2setup-config within the new style build dir: D:\ws\haskell\cabal-test\dist-newstyle\build\x86_64-windows\ghc-8.6.5\cabal-test-0.1.0.0 (no need to hard link another path). In my case there is not an opt subdir... so maybe in macos the hard link is neededcabal-helper0.9.0.0-Cabal2.4.1.0 in %USERPROFILE%\Local settings\Cache\cabal-helper@jneira no luck for me, I still got the readCreateProcess error after following your steps.
We could trace the error thrown by cabal-helper and eventually got to make it work with some effort, but i would follow @fendor suggestion and wait for the mentioned pr and use stack in the meanwhile if you can use it.
Feel free to post the error thrown by executing cabal-helper-wrapper in a shell otherwise.
Most helpful comment
@DanielG has managed to find some time to work on this solidly in the next few months, so rather than doing my band-aid patch, we will wait for his work.
And we are hoping for some assistance from @power-fungus and @fendor too.