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

Fails to index #4

Open
hasufell opened this issue Oct 5, 2018 · 16 comments
Open

Fails to index #4

hasufell opened this issue Oct 5, 2018 · 16 comments
Assignees

Comments

@hasufell
Copy link

hasufell commented Oct 5, 2018

$ haskell-code-indexer --package /home/maerwald/git/hpath --dist dist-newstyle
2018-10-05 11:06:27.113302971 +08 : [info] haskell-code-indexer version 0.1.0.0, GHC version 8.2.2.0
cabal-helper-wrapper: /home/maerwald/git/hpath/dist-newstyle/setup-config: openFile: does not exist (No such file or directory)
2018-10-05 11:06:27.124410555 +08 : [error] readCreateProcess: /home/maerwald/git/haskell-code-explorer/.stack-work/install/x86_64-linux-tinfo6/lts-11.3/8.2.2/libexec/x86_64-linux-ghc-8.2.2/cabal-helper-0.8.0.2/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "/home/maerwald/git/hpath" "/home/maerwald/git/hpath/dist-newstyle" "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

I have no idea why it's trying to get into .stack-work directory of my package. I don't use stack for that package and told it to use dist-newstyle.

@alexwl
Copy link
Owner

alexwl commented Oct 5, 2018

Since the file /home/maerwald/git/hpath/dist-newstyle/setup-config doesn't exist, then it is possible that the package hpath was not built. The package should be built (using cabal or stack) before indexing (i.e., cabal new-build,cabal build, or stack build command should be executed).

Sorry, I should have added that to the README (I will update the README soon).

@hasufell
Copy link
Author

hasufell commented Oct 5, 2018

The package was definitely built.

@alexwl
Copy link
Owner

alexwl commented Oct 5, 2018

Oh, now I see, I've provided an incorrect example in the README. dist directory (where setup-config file is saved) for cabal new-build should be not just dist-newstyle, but something like dist-newstyle/build/x86_64-linux/ghc-8.2.2/hpath-0.9.2.

Can you try to find a directory with setup-config file manually? I'm not sure if there is a cabal command that returns relative path to a dist directory (like stack path --dist-dir).

@hasufell
Copy link
Author

hasufell commented Oct 5, 2018

Yes, that seems to work, but as expected... cabal-helper fails with random errors. It's a plague, really.

@alexwl
Copy link
Owner

alexwl commented Oct 5, 2018

Can you show the output of haskell-code-indexer with --verbose option?

@hasufell
Copy link
Author

hasufell commented Oct 5, 2018

Registering library for Cabal-2.2.0.0..
done
[1 of 4] Compiling CabalHelper.Shared.Common ( /home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/CabalHelper/Shared/Common.hs, /home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/CabalHelper/Shared/Common.o )
[2 of 4] Compiling CabalHelper.Shared.InterfaceTypes ( /home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/CabalHelper/Shared/InterfaceTypes.hs, /home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/CabalHelper/Shared/InterfaceTypes.o )
[3 of 4] Compiling CabalHelper.Shared.Sandbox ( /home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/CabalHelper/Shared/Sandbox.hs, /home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/CabalHelper/Shared/Sandbox.o )
[4 of 4] Compiling Main             ( /home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/CabalHelper/Runtime/Main.hs, /home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/Main.o )

/home/maerwald/.cache/cabal-helper/cabal-helper0.8.0.2-Cabal2.2.0.0.build/CabalHelper/Runtime/Main.hs:47:1: error:
    Could not find module ‘Distribution.PackageDescription.Parse’
    Perhaps you meant
      Distribution.PackageDescription.Parsec (from Cabal-2.2.0.0)
      Distribution.PackageDescription.Check (from Cabal-2.2.0.0)
      Distribution.PackageDescription.Quirks (from Cabal-2.2.0.0)
    Use -v to see a list of the files searched for.
   |
47 | import Distribution.PackageDescription.Parse
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

@alexwl
Copy link
Owner

alexwl commented Oct 5, 2018

cabal-helper-0.8.0.2 that is used by haskell-code-indexer supports only Cabal >=1.14 && <1.26 || ==2.0.*

I should update the cabal-helper package

@LeventErkok
Copy link

I'm having precisely this same issue. Would be great if you could add support!

@hasufell
Copy link
Author

hasufell commented Oct 8, 2018

cabal-helper is a terrible hack. It really just adds more fragility to the tooling ecosystem.

@alexwl
Copy link
Owner

alexwl commented Oct 9, 2018

Of course, compiling and linking cabal-helper executable at runtime is an additional point of failure. Is there a simpler way to get build information (https://www.haskell.org/cabal/release/latest/doc/API/Cabal/Distribution-Simple-LocalBuildInfo.html)? The problem is that a format of setup-config file depends on a version of Cabal library.

@alexwl alexwl self-assigned this Oct 10, 2018
@pwaller
Copy link

pwaller commented Nov 12, 2018

I've hit this. It's trying to pick up MyProjectFoo/bar/dist/setup-config when the path should instead be:

$ cd MyProjectFoo/bar
$ ls
bar.cabal src
$ stack path --dist-dir
.stack-work/dist/x86_64-linux/Cabal-2.0.1.0

(It did work for me for the top level project which lives at MyProjectFoo/)

Is there a workaround for this?

@pwaller
Copy link

pwaller commented Nov 12, 2018

To answer my own question, this appears to work:

stack exec --no-ghc-package-path haskell-code-indexer -- -p . --dist $(stack path --dist-dir)

@alexwl
Copy link
Owner

alexwl commented Nov 12, 2018

When there is no --dist option, haskell-code-indexer tries to find the 'dist' directory: https://haskell-code-explorer.mfix.io/package/haskell-code-explorer-0.1.0.0/show/src/HaskellCodeExplorer/PackageInfo.hs#L315

The logic is as follows: if the package directory contains stack.yaml file, haskell-code-indexer executes stack path --dist-dir command to get the 'dist' directory, otherwise it tries to use the default 'dist' directory dist.

@pwaller
Copy link

pwaller commented Nov 13, 2018

So in my situation there is a MyProjectFoo/stack.yaml but no MyProjectFoo/bar/stack.yaml; the dist directory for bar is at MyProjectFoo/bar/.stack-work/dist/x86_64-linux/Cabal-2.0.1.0. Should the indexer check upper directories for a stack.yaml and if it finds one fall back to running stack path --dist-dir in the CWD?

@hasufell
Copy link
Author

I don't see how this is related to the original issue, which was about using cabal.

@pwaller
Copy link

pwaller commented Nov 13, 2018

Apologies, I've filed a separate issue for that #13.

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

No branches or pull requests

4 participants