Skip to content

Fails to index #4

Description

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

Activity

  1. alexwl commented on Oct 5, 2018

    @alexwl
    Owner

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

  2. hasufell commented on Oct 5, 2018

    @hasufell
    Author

    The package was definitely built.

  3. alexwl commented on Oct 5, 2018

    @alexwl
    Owner

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

  4. hasufell commented on Oct 5, 2018

    @hasufell
    Author

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

  5. alexwl commented on Oct 5, 2018

    @alexwl
    Owner

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

  6. hasufell commented on Oct 5, 2018

    @hasufell
    Author
    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
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
    
  7. alexwl commented on Oct 5, 2018

    @alexwl
    Owner

    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

  8. LeventErkok commented on Oct 6, 2018

    @LeventErkok

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

  9. hasufell commented on Oct 8, 2018

    @hasufell
    Author

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

  10. alexwl commented on Oct 9, 2018

    @alexwl
    Owner

    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.

  11. self-assigned this
    on Oct 10, 2018
  12. pwaller commented on Nov 12, 2018

    @pwaller

    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?

  13. pwaller commented on Nov 12, 2018

    @pwaller

    To answer my own question, this appears to work:

    stack exec --no-ghc-package-path haskell-code-indexer -- -p . --dist $(stack path --dist-dir)
    
  14. alexwl commented on Nov 12, 2018

    @alexwl
    Owner

    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.

  15. pwaller commented on Nov 13, 2018

    @pwaller

    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?

  16. hasufell commented on Nov 13, 2018

    @hasufell
    Author

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

  17. pwaller commented on Nov 13, 2018

    @pwaller

    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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions