haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Failure to load project with spaces on its absolute path

Open arbitrary-dev opened this issue 1 year ago • 3 comments

Your environment

Which OS do you use? Gentoo

Which version of GHC do you use and how did you install it? 9.8.2 compiled from sources

How is your project built?

cabal-version:      3.0
name:               project
version:            0.1.0.0
-- synopsis:
-- description:
license:            NONE
author:             Me
maintainer:         no
-- copyright:
category:           Testing
build-type:         Simple
extra-doc-files:    CHANGELOG.md
-- extra-source-files:

common warnings
    ghc-options: -Wall -main-is Server

executable app
    import:           warnings
    main-is:          Main.hs
    -- other-modules:
    -- other-extensions:
    build-depends:
        ...
    hs-source-dirs:   app
    default-language: GHC2021

Which LSP client (editor/plugin) do you use? neovim + lsp-configs

Which version of HLS do you use and how did you install it? 2.7.0.0 compiled from sources

Have you configured HLS in any way (especially: a hie.yaml file)? Nope

Steps to reproduce

Put a sample project on a path with spaces, e.g:
/tmp/ab c/project

Expected behaviour

HLS successfully loads the project.

Actual behaviour

 Diagnostics:
 Loading the module '/tmp/ab c/project/app/Main.hs' failed.

 It may not be listed in your .cabal file!
 Perhaps you need to add `Main` to other-modules or exposed-modules.

 For more information, visit: https://cabal.readthedocs.io/en/3.4/developing-pa
 ckages.html#modules-included-in-the-package

arbitrary-dev avatar May 12 '24 09:05 arbitrary-dev

Hi, thank you for your bug report!

This seems to be a bug in cabal, see https://github.com/haskell/cabal/issues/8875. That's quite unfortunate, I am not sure whether there is any actionable workaround for this issue.

fendor avatar May 12 '24 14:05 fendor

Perhaps the workaround for HLS would be to allow for a setting to use relative paths when calling Cabal. Because as I see in https://github.com/haskell/cabal/issues/8875 and confirmed locally, using Cabal without specifying the absolute path works just fine. That way I can just initialize HLS while at the root of my project and be just fine. What do you think?

arbitrary-dev avatar May 12 '24 14:05 arbitrary-dev

That workaround is slightly tricky, as we would need to figure out to which .cabal file a filepath is most likely to be relative to.

Also, as I tested in https://github.com/haskell/cabal/issues/8875#issuecomment-2106267103, it is also broken if there are spaces in the hs-source-dir, for which there is no workaround at all.

fendor avatar May 12 '24 14:05 fendor