Skip to content
This repository has been archived by the owner. It is now read-only.

Not working with cabal-2.4.1.0 #1015

Closed
newhoggy opened this issue Dec 30, 2018 · 19 comments
Closed

Not working with cabal-2.4.1.0 #1015

newhoggy opened this issue Dec 30, 2018 · 19 comments

Comments

@newhoggy
Copy link

@newhoggy newhoggy commented Dec 30, 2018

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
@newhoggy
Copy link
Author

@newhoggy newhoggy commented Dec 30, 2018

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
@newhoggy
Copy link
Author

@newhoggy newhoggy commented Dec 30, 2018

After downgrading my cabal file to remove cabal-version: 2.2 and add cabal-version: >= 1.10, the problem still persists.

@newhoggy
Copy link
Author

@newhoggy newhoggy commented Dec 30, 2018

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
@newhoggy
Copy link
Author

@newhoggy newhoggy commented Dec 30, 2018

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
@alanz
Copy link
Collaborator

@alanz alanz commented Dec 30, 2018

@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.

@alanz alanz added this to the 2019-01 milestone Dec 31, 2018
@AlexeyRaga
Copy link
Contributor

@AlexeyRaga AlexeyRaga commented Jan 7, 2019

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?

@AlexeyRaga
Copy link
Contributor

@AlexeyRaga AlexeyRaga commented Jan 7, 2019

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?

@alanz
Copy link
Collaborator

@alanz alanz commented Jan 8, 2019

@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.

@AlexeyRaga
Copy link
Contributor

@AlexeyRaga AlexeyRaga commented Jan 8, 2019

@alanz awesome, thanks! :) Can't wait! :)

@tjarvstrand
Copy link

@tjarvstrand tjarvstrand commented Jan 22, 2019

Any news? I'm eagerly awaiting this! :)

@alanz
Copy link
Collaborator

@alanz alanz commented Jan 28, 2019

@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 alanz modified the milestones: 2019-01, 2019-02 Feb 2, 2019
@alanz alanz modified the milestones: 2019-02, 2019-03 Mar 2, 2019
@alanz alanz modified the milestones: 2019-03, 2019-04 Apr 6, 2019
@alanz alanz modified the milestones: 2019-04, 2019-05 May 4, 2019
@alanz alanz modified the milestones: 2019-05, 2019-06 Jun 1, 2019
@alanz alanz modified the milestones: 2019-06, Some time Jul 7, 2019
@masaeedu
Copy link

@masaeedu masaeedu commented Sep 30, 2019

@alanz Can we document in the README that executable support is currently not working and users should work with library stanzas instead?

@fendor
Copy link
Collaborator

@fendor fendor commented Sep 30, 2019

We can do that.

@razvan-flavius-panda
Copy link

@razvan-flavius-panda razvan-flavius-panda commented Oct 14, 2019

@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?

@fendor
Copy link
Collaborator

@fendor fendor commented Oct 14, 2019

Because HIE can only handle cabal v1-projects at the moment. Support for cabal v2 is coming via #1126

@jneira
Copy link
Collaborator

@jneira jneira commented Oct 14, 2019

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:

  • With cabal-2.4.1.0 in $PATH
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
  • With ghc-8.6.5 shipped with Cabal-2.4.0.1
  • In a windows system
  • Testing with vscode
  • After deleting the cabal-helper cache (in my case in %USERPROFILE%\Local settings\Cache\cabal-helper
  • After run cabal v2-clean && cabal v2-configure in the project
  • hie-version: Version 0.12.0.0 x86_64 ghc-8.6.5 (actual 25678ff built from source with cabal-3.0.0.0 using stack install.hs cabal-hie-8.6.5)
  • hie generated this 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"
  • Note:
    • It has the v1-style option although it is able to handle the project built with v2
    • It has the correct path to setup-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 needed
    • It built cabal-helper0.9.0.0-Cabal2.4.1.0 in %USERPROFILE%\Local settings\Cache\cabal-helper
      (log of hie output in https://gist.github.com/jneira/918048bb504b208239d97d894b9e56c9)
@razvan-flavius-panda
Copy link

@razvan-flavius-panda razvan-flavius-panda commented Oct 14, 2019

@jneira no luck for me, I still got the readCreateProcess error after following your steps.

@jneira
Copy link
Collaborator

@jneira jneira commented Oct 14, 2019

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.

@fendor
Copy link
Collaborator

@fendor fendor commented Dec 20, 2019

#1126 has landed bringing support for cabal v2-* builds!

@fendor fendor closed this Dec 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants