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

multiple components with cabal-install 3.12.1.0 #316

Open
mwotton opened this issue Aug 15, 2024 · 11 comments
Open

multiple components with cabal-install 3.12.1.0 #316

mwotton opened this issue Aug 15, 2024 · 11 comments
Labels
linear Created by Linear-GitHub Sync

Comments

@mwotton
Copy link
Contributor

mwotton commented Aug 15, 2024

What happened?

carrying on from #308 - cabal-install 3.12.1.0 is out now, and the multiple component repl seems to work. unfortunately, ghciwatch crashes:

ghciwatch --command "cabal repl --enable-multi-repl mylib mylib:mylib-test" --watch src --watch test  --test-ghci main

...ghci loading elided...

Ok, 13 modules loaded.
Error:   × Tasks failed:
  │ • run_ghci: Failed to parse `:show targets` output

running cabal repl --enable-multi-repl mylib mylib:mylib-test and running :show targets, it shows my library modules and my test modules, but also 'test/Main.hs' in the list, so perhaps not surprising ghciwatch crashes if it's expecting a module name.

What did you expect to happen?

expected ghciwatch to load and run my tests.

Steps to reproduce the issue

i think you can replicate this with any library with a test component.

The version of ghciwatch with the bug

ghciwatch 1.0.1

@github-actions github-actions bot added the linear Created by Linear-GitHub Sync label Aug 15, 2024
@mwotton
Copy link
Contributor Author

mwotton commented Aug 15, 2024

playing around with it a bit, even if i manually filter test/Main.hs, it still chokes on my test module, which makes sense given that the test source folder isn't in the search_paths at that point.

@mwotton
Copy link
Contributor Author

mwotton commented Aug 15, 2024

(if i'm totally off-base here and there's a good workaround for having ghciwatch reload both tests and code that doesn't require multi-components, please let me know!)

@mwotton
Copy link
Contributor Author

mwotton commented Aug 16, 2024

ah, so the current hack in https://github.com/MercuryTechnologies/ghciwatch/tree/main/tests/data/simple is to just have a single component that pulls in everything? ok, that makes sense.

@mwotton mwotton closed this as completed Aug 16, 2024
@9999years
Copy link
Member

This shouldn't crash, I'd like to support multiple components.

@9999years 9999years reopened this Aug 16, 2024
@eddiemundo
Copy link

Seems like the problem here is that :show paths gives only the paths for a single component and not all of the components so targets from other components can't be found.

Dunno if there is another way of finding the component paths to hack around this?

@9999years
Copy link
Member

@eddiemundo Would you paste some example output? It'll help when I have time to look into this.

@eddiemundo
Copy link

cabal repl --enable-multi-repl component-a component-b component-c
ghci> :show paths
current working directory: 
  /home/jon/projects/my-project
module import search paths:
  src
  /home/jon/projects/my-project/dist-newstyle/build/x86_64-linux/ghc-9.6.6/my-project-0.1.0.0/opt/build
  /home/jon/projects/my-project/dist-newstyle/build/x86_64-linux/ghc-9.6.6/my-project-0.1.0.0/opt/build/autogen
  /home/jon/projects/my-project/dist-newstyle/build/x86_64-linux/ghc-9.6.6/my-project-0.1.0.0/opt/build/global-autogen

cabal repl --enable-multi-repl component-b component-c
ghci> :show paths
current working directory: 
  /home/jon/projects/my-project
module import search paths:
  modules/component-b/src
  /home/jon/projects/my-project/dist-newstyle/build/x86_64-linux/ghc-9.6.6/my-project-0.1.0.0/l/component-b/opt/build/component-b
  /home/jon/projects/my-project/dist-newstyle/build/x86_64-linux/ghc-9.6.6/my-project-0.1.0.0/l/component-b/opt/build/component-b/autogen
  /home/jon/projects/my-project/dist-newstyle/build/x86_64-linux/ghc-9.6.6/my-project-0.1.0.0/l/component-b/opt/build/global-autogen

So seems like when using cabal repl --enable-multi-repl :show paths only returns the module search paths for the first component listed, and so ghciwatch can't find targets of the non-first components because it only searches through the first component's search paths. There may be other problems afterwards, but this is the source of the crash I'm pretty sure.

@georgefst
Copy link

I'd love to see this! I'm finding multi-component support in GHCID to be broken, with file changes often not picked up. And I'd rather just switch to this project than debug that one.

@9999years
Copy link
Member

@georgefst Unless we can find a way to query GHCi for all the search paths, I'm not sure this is fixable. This might need a patch to GHC or Cabal (not sure which one) before it's usable with either ghcid or ghciwatch.

@georgefst
Copy link

This might need a patch to GHC or Cabal (not sure which one) before it's usable with either ghcid or ghciwatch.

I haven't looked in to how it works (or why it doesn't for me), but it's been stated here and here that it already works with GHCID.

@9999years
Copy link
Member

9999years commented Dec 5, 2024

@georgefst Ahh, good point, I wasn't thinking carefully. I suspect that the reason it works with ghcid is that ghcid takes the naïve approach of waiting for files to change and issuing a :reload when they do. ghciwatch is much more careful and actually tracks which files are loaded and what modules they correspond to, so it needs to know all the search paths. (This enables --repl-no-load support.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

4 participants