You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stack ghci/repl with internal sublibraries only works after a build #4148
changed the title [-]GHCi with internal libraries only works after a build[/-][+]stack ghci/repl with internal sublibraries only works after a build[/+]on Jun 17, 2023
@mihaimaruseac@mpilgrem : This issue has a milestone P0: blocking release from 2018. Maybe this milestone needs update, or is it intended that this issue will be fixed for the next release? (Would be nice.)
@andreasabel, I've cleared the 'milestone' label as it was misleading. I'll likely find a different way of labelling the most important issues. I consider this issue to be one of the most important (in the top 3) because it interferes with the mechanism that HLS uses to get information from Stack.
Reacted by Andreas Abel, Mihai Maruseac and Maxim Ivanov
Regarding implementation, I thought it was something easy back in 2018, but I realized I needed much more time to understand Stack's codebase. Then had a job change and didn't get a chance to look much into it, but hoping to be able to pick it again in the enar future.
To confirm: this still affects the master branch version of Stack (Version 2.14.0, Git revision 8c02ca86caacc1c30f16df91f5cc475375bed667 (10100 commits) PRE-RELEASE x86_64). Tested with a simple one-package project ghciTest, with package.yaml:
spec-version: 0.36.0name: ghciTestversion: 0.1.0.0dependencies:
- base >= 4.7 && < 5library:
source-dirs: srcdependencies:
- subinternal-libraries:
sub:
source-dirs: sub
> stack purge
❯ stack ghci
ghciTest> configure (lib + sub-lib)
Configuring ghciTest-0.1.0.0...
ghciTest> initial-build-steps (lib + sub-lib)
Configuring GHCi with the following packages: ghciTest.
GHCi, version 9.4.7: https://www.haskell.org/ghc/ :? for help
<command line>: cannot satisfy -package z-ghciTest-z-sub
(use -v for more information)
❯ stack build
ghciTest> build (lib + sub-lib)
Preprocessing library 'sub' for ghciTest-0.1.0.0..
Building library 'sub' for ghciTest-0.1.0.0..
[1 of 1] Compiling SubLib
Preprocessing library for ghciTest-0.1.0.0..
Building library for ghciTest-0.1.0.0..
[1 of 1] Compiling Lib
ghciTest> copy/register
Installing internal library sub in D:\Users\mike\Code\Haskell\ghciTest\.stack-work\install\d537d1c2\lib\x86_64-windows-ghc-9.4.7\ghciTest-0.1.0.0-Lgr8UKNJkvT1kMCZcjHaWw-sub
Installing library in D:\Users\mike\Code\Haskell\ghciTest\.stack-work\install\d537d1c2\lib\x86_64-windows-ghc-9.4.7\ghciTest-0.1.0.0-AgYgWsPNk3w95cAA2YGFHT
Registering library 'sub' for ghciTest-0.1.0.0..
Registering library for ghciTest-0.1.0.0..
❯ stack ghci
Configuring GHCi with the following packages: ghciTest.
GHCi, version 9.4.7: https://www.haskell.org/ghc/ :? for help
[1 of 2] Compiling SubLib ( D:\Users\mike\Code\Haskell\ghciTest\sub\SubLib.hs, interpreted )
[2 of 2] Compiling Lib ( D:\Users\mike\Code\Haskell\ghciTest\src\Lib.hs, interpreted )
Ok, two modules loaded.
Loaded GHCi configuration from C:\Users\mikep\AppData\Local\stack\ghci-script\8af0ba7e\ghci-script
ghci>
@ulidtko, my-acme-package:lib:my-internal-sublib is not a valid Stack target and I would not expect HLS to be using it. Are you using a hie.yaml 'cradle' and, if so, how is it configured?
cradle:
stack:
- path: ./app/Apiserver.hscomponent: my-acme-package:exe:apiserver
- path: ./testcomponent: my-acme-package:test:test
- path: ./src#component: my-acme-package:lib:my-internal-sublib#-- Can't specify the correct component name; it also fails to autodetect,#-- because of https://github.com/commercialhaskell/stack/issues/4148#-- Point HLS to "this directory" instead, and hope for the best.component: .
Something I failed to figure out and gave up on: Cabal docs, logs & source seem to suggest that these "internal sublibs" are also cabal package components.
Aren't they? stack ide targets doesn't list them, the paths mangle into the funny structure z-my-acme-package-z-my-internal-sublib, HLS (hie-bios?..) doesn't autodetect them, and apparently I can't name them in hie.yaml either.
However all that looks like just stack lacking proper support for named/internal/sub- libs.
So naturally, we'd think about named sublibs as cabal package components — and therefore, valid stack targets — but it's guessable that actually they're heavily specialcased in stack, and supported very differently than other types of components.
@ulidtko, currently, Stack's target syntax my-package:lib targets all of the library components of package my-package. 'Currently' because #6042 is on my radar.
From my reading of this and related issues - is it correct that the way to fix this is basically to achieve component-based builds #6356?
Edit: because the text of that says "it's a hard requirement for making backpack work (backpack cannot work with current style builds). " - and now with Stack 4.1, full Backpack support was actually achieved. So does that mean that component-based builds were achieved and this particular issue is that much more solvable?
@mikeplus64, @philippedev101 is better placed than me to answer your question reliably, but I think the short answer is that Backpack support in (coming) Stack 4.1.1 was acheived without implementing fully component-based builds. See the question and answer at:
Activity
Ensure we build before ghci, due to #4148.
Merge pull request #4149 from commercialhaskell/mm-fix-ghci-sublibs-test
dbaynard commentedon Jul 18, 2018
@mihaimaruseac it would be good to get this working or add a note to the docs, before the next release.
mihaimaruseac commentedon Jul 18, 2018
I'm travelling at the moment, so won't be able to get it working, most likely. Will come back to this on Friday and do one or the other
dbaynard commentedon Jul 21, 2018
Related: #2790 (possibly a duplicate)
Document that `stack ghci` works best only after `stack build`.
Document that `stack ghci` works best only after `stack build`.
mihaimaruseac commentedon Jul 28, 2018
Added documentation for this, will try solving it later when I get some time to dwell deep into the code.
adamschoenemann commentedon Nov 21, 2018
I have this problem on 1.9.1 also (just fyi)
dbaynard commentedon Nov 21, 2018
It hasn't been fixed — just documented, for now.
11 remaining items
[-]GHCi with internal libraries only works after a build[/-][+]stack ghci/repl with internal sublibraries only works after a build[/+]andreasabel commentedon Oct 15, 2023
I am running into this in the
hasktorchproject:andreasabel commentedon Nov 3, 2023
@mihaimaruseac @mpilgrem : This issue has a milestone
P0: blocking releasefrom 2018. Maybe this milestone needs update, or is it intended that this issue will be fixed for the next release? (Would be nice.)mpilgrem commentedon Nov 3, 2023
@andreasabel, I've cleared the 'milestone' label as it was misleading. I'll likely find a different way of labelling the most important issues. I consider this issue to be one of the most important (in the top 3) because it interferes with the mechanism that HLS uses to get information from Stack.
mihaimaruseac commentedon Nov 3, 2023
Regarding implementation, I thought it was something easy back in 2018, but I realized I needed much more time to understand Stack's codebase. Then had a job change and didn't get a chance to look much into it, but hoping to be able to pick it again in the enar future.
mpilgrem commentedon Nov 5, 2023
To confirm: this still affects the
masterbranch version of Stack (Version 2.14.0, Git revision 8c02ca86caacc1c30f16df91f5cc475375bed667 (10100 commits) PRE-RELEASE x86_64). Tested with a simple one-package projectghciTest, withpackage.yaml:mpilgrem commentedon Nov 5, 2023
The command that fails is this (reformatted):
The command that succeeds is this (reformatted), the difference is the
-package=is replaced by-package-id=:ulidtko commentedon Apr 15, 2024
Also hitting this, with HLS... bump + subscribe.
mpilgrem commentedon Apr 15, 2024
@ulidtko,
my-acme-package:lib:my-internal-sublibis not a valid Stack target and I would not expect HLS to be using it. Are you using ahie.yaml'cradle' and, if so, how is it configured?ulidtko commentedon Apr 17, 2024
@mpilgrem yes, using hand-written cradle:
Something I failed to figure out and gave up on: Cabal docs, logs & source seem to suggest that these "internal sublibs" are also cabal package components.
Aren't they?
stack ide targetsdoesn't list them, the paths mangle into the funny structurez-my-acme-package-z-my-internal-sublib, HLS (hie-bios?..) doesn't autodetect them, and apparently I can't name them inhie.yamleither.However all that looks like just stack lacking proper support for named/internal/sub- libs.
For example here, Cabal defines ComponentName as:
and LibraryName is either the single
MainLib, or a namedSubLib:So naturally, we'd think about named sublibs as cabal package components — and therefore, valid stack targets — but it's guessable that actually they're heavily specialcased in stack, and supported very differently than other types of components.
mpilgrem commentedon Apr 17, 2024
@ulidtko, currently, Stack's target syntax
my-package:libtargets all of the library components of packagemy-package. 'Currently' because #6042 is on my radar.mikeplus64 commentedon Sep 1, 2026
From my reading of this and related issues - is it correct that the way to fix this is basically to achieve component-based builds #6356?
Edit: because the text of that says "it's a hard requirement for making backpack work (backpack cannot work with current style builds). " - and now with Stack 4.1, full Backpack support was actually achieved. So does that mean that component-based builds were achieved and this particular issue is that much more solvable?
mpilgrem commentedon Sep 2, 2026
@mikeplus64, @philippedev101 is better placed than me to answer your question reliably, but I think the short answer is that Backpack support in (coming) Stack 4.1.1 was acheived without implementing fully component-based builds. See the question and answer at: