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

HtProjectHelpers.get_package_name should read from stack.yaml instead of inferring from project directory name #342

Open
gabrielsimoes opened this issue Feb 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@gabrielsimoes
Copy link

Neovim version (nvim -v)

0.9.5

Operating system/version

Arch

Output of :checkhealth haskell-tools

==============================================================================
haskell-tools: require("haskell-tools.health").check()

Checking for Lua dependencies ~
- OK [nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) installed.

Checking external dependencies ~
- OK haskell-language-server: found haskell-language-server version: 2.5.0.0 (GHC: 9.2.8) (PATH: /home/gabriel/.ghcup/hls/2.5.0.0/lib/haskell-language-server-2.5.0.0/bin/haskell-language-server-wrapper)
- WARNING       hoogle: not found.
  Install [ndmitchell/hoogle](https://github.com/ndmitchell/hoogle) for extended capabilities.
  Recommended for better Hoogle search performance.
  Without a local installation, the web API will be used by default.
  Required if the hoogle mode is set to "telescope-local".
  
  
- WARNING       fast-tags: not found.
  Install [fast-tags](https://hackage.haskell.org/package/fast-tags) for extended capabilities.
  Optional, for generating tags as a `tagfunc` fallback.
  
- OK curl: found curl 8.6.0 (x86_64-pc-linux-gnu) libcurl/8.6.0 OpenSSL/3.2.1 zlib/1.3.1 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.7 libpsl/0.21.2 libssh2/1.11.0 nghttp2/1.59.0
- WARNING       haskell-debug-adapter: not found.
  Install [haskell-debug-adapter](https://github.com/phoityne/haskell-debug-adapter) for extended capabilities.
  Optional, for `dap` support.
  
- WARNING       ghci-dap: not found.
  Install [ghci-dap](https://github.com/phoityne/ghci-dap) for extended capabilities.
  Optional, for `dap` support.
  

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

How to reproduce the issue

Opening the REPL :HtReplToggle will fail to import a project in case the project's directory does not match the package name in stack.yaml. The plugin will execute stack ghci <DIRECTORY_NAME> instead of stack ghci <PROJECT_NAME> and stack will error:

Warning: Some targets (<DIRECTORY_NAME>) are not local packages, and so cannot be directly loaded. In future versions of Stack, this might be supported - see https://github.com/commercialhaskell/stack/issues/1441 . It can still be useful to specify these, as they will be passed to ghci via -package flags.

Note: No local targets specified, so a plain ghci will be started with no package hiding or package options.
 
You are using snapshot: lts-21.25

If you want to use package hiding and options, then you can try one of the following:

* If you want to start a different project configuration than <DIRECTORY>/stack.yaml, then you can use stack init to create a new stack.yaml for the packages in the current directory. 
 * If you want to use the project configuration at <DIRECTORY>/stack.yaml, then you can add to its 'packages' field.

Expected behaviour

stach ghci <PROJECT_NAME> is called.

Actual behaviour

stack ghci <DIRECTORY_NAME> is called.

Log files

No response

The minimal config used to reproduce this issue.

default config
@gabrielsimoes gabrielsimoes added the bug Something isn't working label Feb 8, 2024
@mrcjkb
Copy link
Owner

mrcjkb commented Feb 8, 2024

Hey 👋

Thanks for reporting.
Some notes from myself:

  • We'll have to handle both package.yaml and .cabal cases (though I think in the case of cabal it can be inferred from the file name).
  • We should fall back to the directory name, as vim.json.decode doesn't work with yaml, and manual parsing is brittle.
  • Ideally, both Stack and Cabal should provide a metadata command, similar to Cargo's, that would output project metadata as JSON.

I'll look into a hotfix after work later today.

@gabrielsimoes
Copy link
Author

gabrielsimoes commented Feb 8, 2024

Thanks for taking a look! I am not personally blocked[1] but thought I would report in case other people hit the same issue/for documentation. Thanks for developing this plugin.

[1] Especially since I found symlinks work around the issue (a symlink pointing to a directory with the right package name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants