-
Notifications
You must be signed in to change notification settings - Fork 112
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
Multi-project stack does not properly reload #57
Comments
after some more experimentation, I didn't find any way for me to reload default ghcid command when any */.hs change. |
Reload can take a directory name or a file name. It can't take patterns and it doesn't deal with recursive directories. These are deliberate limitations - things that could be fixed, but generally needing super-powerful reloading is a good sign that something else is broken. In this case, clearly something else is broken! It should be all automatic. When you run
What is the associated command? If you run the associated command (e.g. |
@ndmitchell $ stack ghci --test --no-load --ghci-options=-fno-code
Configuring GHCi with the following packages: cogito, app, orm, pghs, types
GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help
Prelude> :show modules
Prelude> but...
|
Do you have a |
No, I don't have a .ghci file (sorry, I was still writing the other part of my answer ^^) |
Completely makes sense to me the strange thing (bug?) is that
but
and
but in both cases, it doens't reload modules of local-dep-1 also, sorry for editing my original message at the same time you were reading it, but I included more details in it. Thanks for being super responsive on that :) |
Let's focus on the first problem first - why doesn't just plain vanilla
What command do you use to start |
I made this repo for you to reproduce easilly https://github.com/rvion/ghcid-bug-repro if you clone it and run Neither to answer you questions:
I always launch command from the root project folder.
(slightly edited) toplevelpackage $ ls -la
total 96
drwxr-xr-x 16 rvion staff 544 Apr 12 18:34 .git
-rw-r--r-- 1 rvion staff 212 Apr 11 14:05 .gitignore
drwxr-xr-x 6 rvion staff 204 Apr 11 13:31 .stack-work
-rw-r--r-- 1 rvion staff 196 Apr 12 12:27 TopLevelPackage.hs
-rw-r--r-- 1 rvion staff 4823 Apr 11 16:02 README.md
drwxr-xr-x 9 rvion staff 306 Apr 11 16:02 app
drwxr-xr-x 6 rvion staff 204 Apr 6 17:09 arch
drwxr-xr-x 9 rvion staff 306 Mar 19 11:09 auth
drwxr-xr-x 13 rvion staff 442 Apr 7 09:49 client
-rw-r--r-- 1 rvion staff 1086 Apr 12 09:27 toplevelpackage.cabal
-rw-r--r-- 1 rvion staff 632 Apr 12 09:27 toplevelpackage.hpack.yaml
drwxr-xr-x 3 rvion staff 102 Apr 11 12:23 doc
drwxr-xr-x 6 rvion staff 204 Apr 11 14:06 org
drwxr-xr-x 11 rvion staff 374 Apr 12 13:03 orm
drwxr-xr-x 8 rvion staff 272 Apr 11 15:38 pghs
drwxr-xr-x@ 7 rvion staff 238 Apr 11 12:25 scripts
drwxr-xr-x 5 rvion staff 170 Apr 11 14:09 sql
-rw-r--r-- 1 rvion staff 968 Apr 11 16:14 stack.yaml
drwxr-xr-x 6 rvion staff 204 Apr 11 16:03 types
No
as I wrote in (my comment above) here is the output of a plain
|
ok. I finally understood the problem (or at least a good part of it): stack ghci has a this is working fine for me: ghcid -c "stack ghci toplevelmodule --load-local-deps" --test="..." now, the last thing to figure out is why the default plain |
Thanks for the analysis. I'm afraid I didn't get time to look at it in detail yet, and probably won't until next week - but do hope to take a look pretty soon. |
Thanks :) |
Thanks for the test case. The issue is that Stack drops us out at:
Ghcid then sends some essential configuration commands to GHCi to allow it to detect loading has finished. They get sent to that prompt, and thus do nothing. As a result, ghcid can't tell that loading finished. I tried sending an extra |
Hmm, it actually seems that Stack is swallowing subsequent commands. If I create a file
And run:
Then the line |
It's probably because we're passing over control of stdout / stdin to the ghci project, but that doesn't pass along the buffered input. Just a guess! I suppose the fix would be to greedily read as much input as possible. I'm actually a little surprised this doesn't just work. |
@mgsloan, that was my guess too - I wondered if setting LineBuffering/NoBuffering explicitly on stdin might help. I do that on my side, but it would need to be present in the Stack side too - and even then might make no difference if the buffering happens somewhere you can't see it. |
I tried One approach might be to pass in |
I tried no buffering in a small sample program, in both Haskell and C, and in neither case could I get the child process to pick up stdin. It just seems to be "not possible" as far as I can tell. For
So an easier alternative would be to ask Stack to not put that, and pick the default. Is that an option @mgsloan? |
True, it may be necessary to make ghcid know about stack. I realize that's counter the minimalist design, but hey, if we want the functionality
I believe it's possible to generate ghci scripts that tend to play well with others - see commercialhaskell/stack#1888
Yup, that's a viable option, lets do that. Something like |
It would be nice for this to work!
Yeah, looks good. We still have the (experimental) flag in stack so nbd 😂 |
I had a thought for how to solve this. What if |
Yep, that might work - will give it a whirl. |
I followed @mgsloan's suggestion, and it worked. With that, I can load up the project properly. I am not using I'm still gently unwary with waiting for the |
This doesn't work because:
Now trying to only send |
I implemented something which looks for a Stack line and send the |
OK, I've implemented more hacks, and I think it's now working. It is quite unpleasant, and I worry about the long-term robustness. |
Cool! Yeah, not super pleasant I realize. Thanks for making it happen! We could also add a flag, certainly. |
I've put all the stack requests into commercialhaskell/stack#1948 (comment) so closing this. |
@ndmitchell I have a problem with ghcid 0.6.1
*It is currently impossible to start ghcid so it reloads my code when some .hs file change in my multi-package project
I use stack, I have a set of ~10 packages within one same folder.
All of them have a src folder containing module tree (Foo.hs, Foo/Bar.hs, etc.)
I have one empty package at the top level importing all other packages to simplify compatibility with cabal specific stuff (like haskell-ide-atom).
default doesn't work
ghcid
--> never reload when any file changes(this is probably a bug 🐛 related to this message printed in ghci: )
command to load top level package doesn't work because it doesn't watch local deps change
`ghcid -c "stack ghci toplevelpackage"
one reload param with list of file doesn't watch
ghcid --test="testFunction" --reload="**/*.hs"
-> loop weirdly because of "*/.hs"one --reload per folder doesn't work because no recursivity
ghcid --reload pkg1 --reload pkg2
--> never reload when pkg1/src/*/.hs change because only watch for pkg1/* (direct folder, no recursive)So far: the only 2 solutions I thought about were
make a giant cmd like
possible partial workaround:
ghcid $(ls **/*.hs | while read -r line; do dirname "$line"; done | uniq | sed 's/^/--reload=/' | tr '\n' ' ' | sed 's/ $//g')
start one ghcid cmd per package
I went with (1) but then I found a bug 🐛 in ghcid:
doens't reload anything unless I'm specifying a target.
since I have several executables, not specifying a target shows
and then no reload occurs at all
so I did
ghcid -c "stack ghci toplevelpackage" --reload=pkg1/src/ --reload=pkg1/src/Foo --reload=...
but arg again: ghci don't reload files in pkg1 since I specified
toplevelpackage
. sotoplevelpackage
reload when I change pkg1, but it doesn't pick changes in pkg1Otherwise, great project ! Thanks
The text was updated successfully, but these errors were encountered: