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

Internal library component not available for REPL #4564

Closed
rikvdkleij opened this issue Feb 5, 2019 · 38 comments
Closed

Internal library component not available for REPL #4564

rikvdkleij opened this issue Feb 5, 2019 · 38 comments
Assignees

Comments

@rikvdkleij
Copy link

Cabal 2 support internal libraries and as I understand Stack version 1.9.3 also.

I expect that that stack ide targets gives all components but the internal libraries are not mentioned.
Also stack repl [name of lib] does not work.

Steps to reproduce

Create cabal file packagename.cabal which contains components:
library
library libname

Expected

To work:
stack repl packagename:lib:libname

REPL is started.

Actual

What actually happened.
Error parsing targets: Directory not found: packagename:lib:libname

Also when I start a REPL with a component which depends on the internal library, the internal modules can not be loaded.

Stack version

1.9.3

@dbaynard
Copy link
Contributor

dbaynard commented Feb 5, 2019

@mihaimaruseac Would you take a look, please?

@dbaynard
Copy link
Contributor

dbaynard commented Feb 5, 2019

@rikvdkleij Thanks for the report. Would you please indicate which platform you are on, paste the output of stack --version, and also paste the verbose logs corresponding to the error messages (you can wrap the log in <details></details> tags)?

@rikvdkleij
Copy link
Author

Platform is macOS.

stack --version
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1

What do you mean with the details tags? I can can run the command with the --verbose flag and then?

@mihaimaruseac
Copy link
Contributor

See also #4148, unfortunately until March I don't really have time to look into this due to personal reasons. Hopefully after March I can get back to making internal libraries work as they should everywhere in Stack.

@rikvdkleij, you can copy the output of --verbose and paste it in a comment here, between

<details> ` ` `

and

` ` `</details>

(just make sure you remove the spaces between the ` characters). The output would look like

``` This is something from the output. Another line of the output. And yet another one. And so on and on and on ... ```

@mihaimaruseac mihaimaruseac self-assigned this Feb 5, 2019
@rikvdkleij
Copy link
Author

rikvdkleij commented Feb 5, 2019

@mihaimaruseac Thanks for your reply! Great that you will solve this issue! Currently this is a blocker to use internal libraries. Also for IDE support.

Verbose log in which did some renaming:

Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
2019-02-05 15:23:05.618589: [debug] Checking for project config at: rik/app/stack.yaml
2019-02-05 15:23:05.618954: [debug] Loading project config file stack.yaml
2019-02-05 15:23:05.620342: [debug] Decoding build plan from: /Users/rik/.stack/build-plan/lts-12.26.yaml
2019-02-05 15:23:05.620396: [debug] Trying to decode /Users/rik/.stack/build-plan-cache/lts-12.26.cache
2019-02-05 15:23:05.622568: [debug] Success decoding /Users/rik/.stack/build-plan-cache/lts-12.26.cache
2019-02-05 15:23:05.625808: [debug] Potential GHC builds: standard
2019-02-05 15:23:05.625887: [debug] Found already installed GHC builds: standard
2019-02-05 15:23:05.626380: [debug] Getting global package database location
2019-02-05 15:23:05.626609: [debug] Getting Cabal package version
2019-02-05 15:23:05.626657: [debug] Asking GHC for its version
2019-02-05 15:23:05.626771: [debug] Run process: /Users/rik/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db list --global
2019-02-05 15:23:05.627500: [debug] Run process: /Users/rik/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2019-02-05 15:23:05.628207: [debug] Run process: /Users/rik/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc --numeric-version
2019-02-05 15:23:05.718585: [debug] Process finished in 91ms: /Users/rik/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2019-02-05 15:23:05.718777: [debug] Process finished in 92ms: /Users/rik/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db list --global
2019-02-05 15:23:05.731800: [debug] Process finished in 103ms: /Users/rik/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc --numeric-version
2019-02-05 15:23:05.731908: [debug] GHC version is: ghc-8.4.4
2019-02-05 15:23:05.731987: [debug] Resolving package entries
2019-02-05 15:23:05.732114: [debug] Trying to decode /Users/rik/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.4.4/lts-12.26.cache
2019-02-05 15:23:05.769709: [debug] Success decoding /Users/rik/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.4.4/lts-12.26.cache
2019-02-05 15:23:05.770064: [debug] Starting to execute command inside EnvConfig
2019-02-05 15:23:05.770115: [debug] Parsing the targets
2019-02-05 15:23:05.792059: [debug] Trying to decode /Users/rik/.stack/indices/Hackage/01-index.cache
2019-02-05 15:23:06.004836: [debug] Success decoding /Users/rik/.stack/indices/Hackage/01-index.cache
2019-02-05 15:23:06.026014: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow/tensorflow.cabal
2019-02-05 15:23:06.051028: [debug] Finished in 25ms: getPackageFiles rik/tensorflow-haskell/tensorflow/tensorflow.cabal
2019-02-05 15:23:06.052236: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-core-ops/tensorflow-core-ops.cabal
2019-02-05 15:23:06.053083: [debug] Finished in 1ms: getPackageFiles rik/tensorflow-haskell/tensorflow-core-ops/tensorflow-core-ops.cabal
2019-02-05 15:23:06.053873: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-logging/tensorflow-logging.cabal
2019-02-05 15:23:06.061639: [debug] Finished in 8ms: getPackageFiles rik/tensorflow-haskell/tensorflow-logging/tensorflow-logging.cabal
2019-02-05 15:23:06.062817: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-mnist/tensorflow-mnist.cabal
2019-02-05 15:23:06.078738: [debug] Finished in 16ms: getPackageFiles rik/tensorflow-haskell/tensorflow-mnist/tensorflow-mnist.cabal
2019-02-05 15:23:06.080513: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-mnist-input-data/tensorflow-mnist-input-data.cabal
2019-02-05 15:23:06.084524: [debug] Finished in 4ms: getPackageFiles rik/tensorflow-haskell/tensorflow-mnist-input-data/tensorflow-mnist-input-data.cabal
2019-02-05 15:23:06.085547: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-opgen/tensorflow-opgen.cabal
2019-02-05 15:23:06.089598: [debug] Finished in 4ms: getPackageFiles rik/tensorflow-haskell/tensorflow-opgen/tensorflow-opgen.cabal
2019-02-05 15:23:06.090695: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-ops/tensorflow-ops.cabal
2019-02-05 15:23:06.197660: [debug] Finished in 107ms: getPackageFiles rik/tensorflow-haskell/tensorflow-ops/tensorflow-ops.cabal
2019-02-05 15:23:06.198739: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-proto/tensorflow-proto.cabal
2019-02-05 15:23:06.251441: [debug] Finished in 53ms: getPackageFiles rik/tensorflow-haskell/tensorflow-proto/tensorflow-proto.cabal
2019-02-05 15:23:06.254476: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-records/tensorflow-records.cabal
2019-02-05 15:23:06.258472: [debug] Finished in 4ms: getPackageFiles rik/tensorflow-haskell/tensorflow-records/tensorflow-records.cabal
2019-02-05 15:23:06.259349: [debug] Start: getPackageFiles rik/tensorflow-haskell/tensorflow-records-conduit/tensorflow-records-conduit.cabal
2019-02-05 15:23:06.261253: [debug] Finished in 2ms: getPackageFiles rik/tensorflow-haskell/tensorflow-records-conduit/tensorflow-records-conduit.cabal
2019-02-05 15:23:06.262226: [debug] Start: getPackageFiles rik/app/app.cabal
2019-02-05 15:23:06.276925: [debug] Finished in 15ms: getPackageFiles rik/app/app.cabal
2019-02-05 15:23:06.281968: [debug] Parsing the targets
Error parsing targets: Directory not found: app:lib:detection
Note that to specify options to be passed to GHCi, use the --ghci-options flag

@rikvdkleij
Copy link
Author

@mihaimaruseac Later on I added spaces between the ` but did not see a difference in output Also noticed that you have changed the content.

@mihaimaruseac
Copy link
Contributor

I tried to get the formatting fixed but failed. It's ok though, the log is readable. Thank you for it

@dbaynard
Copy link
Contributor

dbaynard commented Feb 5, 2019

You need a blank line between the html tags and the backticks 👍.

@rikvdkleij
Copy link
Author

@dbaynard Thanks!

@dbaynard
Copy link
Contributor

dbaynard commented Feb 5, 2019

Do the other commands work, e.g. build?

@rikvdkleij
Copy link
Author

Yes, stack build works.

@dbaynard
Copy link
Contributor

dbaynard commented Feb 5, 2019

And to be clear, this is different to #4148 (i.e. it still doesn't work after running stack build)?

@rikvdkleij
Copy link
Author

rikvdkleij commented Feb 5, 2019

Yes, that's right. Even after a build it does not work.

Also when I do stack repl without mentioning a component and select a component which depends on an internal library, it takes the language extensions from other components in scope (defined in cabal file).

@mihaimaruseac
Copy link
Contributor

I think #4148 is no longer valid, the last comment there says that ghci after build no longer works (so probably we had a regression there, though since internal libraries support needs to be redone I don't think we should bother bisecting and reverting)

Also when I do stack repl without mentioning a component and select a component which depends on an internal library, it takes the language extensions from other components in scope (defined in cabal file).

Can you open another issue for that, please? And assign to me too, I'll take care of it too next month (or earlier if I get time)

@rikvdkleij
Copy link
Author

@mihaimaruseac

Can you open another issue for that, please? And assign to me too, I'll take care of it too next month (or earlier if I get time)

Isn't this the same issue only it appears differently?

@hgrano
Copy link

hgrano commented Jun 23, 2019

I also am facing this issue. Is there any workaround that could be used while the issue is not fixed? See my details below:

OS - Ubuntu 18.04, stack --version:
Version 2.1.1, Git revision f612ea85316bbc327a64e4ad8d9f0b150dc12d4b (7648 commits) x86_64 hpack-0.31.2

Even after stack build runs successfully, this happens. Also, I have the letter z inserted into the package names, similar to #4148

@bravit
Copy link

bravit commented Jun 30, 2019

This issue affects me a lot, as my readers are not able to use stack for exploring the code in the hid-examples package which contains many executables and internal libraries.

@tkaaad97
Copy link
Contributor

It may not be the same problem, but also in my environment launching stack repl and stack ghci failed in a project that includes an internal library.

The same error occurred when used stack version 1.9.3 and 2.1.1.

The error is below.

[debug] Run process: /opt/ghc/8.6.4/bin/ghc --interactive -i -odir=/home/user/workspace/haskell/experiment1/.stack-work/odir -hidir=/home/user/workspace/haskell/experiment1/.stack-work/odir -hide-all-packages -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build -i/home/user/workspace/haskell/experiment1/src -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/autogen -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/global-autogen -stubdir=/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build -package=z-experiment1-z-experiment1-lib -package-id=base-4.12.0.0 -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/experiment1-lib -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/experiment1-lib/autogen -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/experiment1-lib/experiment1-lib-tmp -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/experiment1-exe -i/home/user/workspace/haskell/experiment1/app -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/experiment1-exe/autogen -i/home/user/workspace/haskell/experiment1/.stack-work/dist/x86_64-linux/Cabal-2.4.0.1/build/experiment1-exe/experiment1-exe-tmp -rtsopts -with-rtsopts=-N -optP-include -optP/home/user/workspace/haskell/experiment1/.stack-work/ghci/6c66921b/cabal_macros.h -ghci-script=/tmp/haskell-stack-ghci/83e92d34/ghci-script
GHCi, version 8.6.4: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package z-experiment1-z-experiment1-lib
    (use -v for more information)

I do not know how it works, but with the option of --no-package-hiding I was able to start ghci.

@hgrano
Copy link

hgrano commented Jul 13, 2019

The error message I got was almost the same as yours @tkaaad97. The --no-package-hiding option also solved it for me, so thanks for that suggestion. Would be good to know why that fixed it

@cdupont
Copy link

cdupont commented Oct 29, 2019

Hi, I have this issue:

$ stack ghci foo:bar
<command line>: cannot satisfy -package z-foo-z-foo-lib
    (use -v for more information)

I also have the letter "z" appended.
If I run with --no-package-hiding:

$ stack ghci foo:bar --no-package-hiding
<no location info>: error:
    module ‘main:Main’ is defined in multiple files: /home/me/foo/bar/Main.hs 
                                                     /home/me/foo/bar/Main.hs

GHCi complains that there is two Main.hs (twice the same). My version of stack is 2.1.3.

@qrilka
Copy link
Contributor

qrilka commented Jul 16, 2020

BTW I think this is a duplicate of #2790

@edwardb96
Copy link

So after playing around with some minimal (non) working examples I have established the following two things about both
Version 2.3.1, Git revision de2a7b694f07de7e6cf17f8c92338c16286b2878 (8103 commits) x86_64 hpack-0.33.0
and recent stack from master which includes #5306 and a bumped version of hpack Version 2.4.0, Git revision b5d30906ebee25df1f2532255e245d329083b623 (dirty) (8168 commits) PRE-RELEASE x86_64 hpack-0.34.2.

When running stack repl without first completing a successful stack build in a project using internal-libraries you get an error message of the form below. This is as described in #2790 and for the moment is avoided by completing stack build before stack repl.

<command line>: cannot satisfy -package z-stack-internal-libs-z-alib
    (use -v for more information)

b) Further to this however, if the package.yaml includes an executable target(s), and an internal-library but no root library: component then this error does not go away after completing a successful stack build.

I attach zipped project which can (hopefully) be used to reproduce this.

I assume this is a bug in stack and that a root library: should not be required? If this were not the case then I would expect stack build to have failed or at least to get a clearer error message from stack repl.

The good news is that in the short term an easy fix to b) is to simply add a root library component with an empty module.

@qrilka
Copy link
Contributor

qrilka commented Jul 27, 2020

I had another look into this and it appears that it's another example of a problem appearing because we don't have yet component-based builds (i.e. #4745) implemented. Currently Stack only has some special handling for "ordinary" components, i.e. executables, benchmarks and tests and internal libraries are handled as an extra step of building a package library. And as I've said in #5342 I don't think I myself can find enough time to implement that ticket.

@isovector
Copy link
Contributor

Any updates on this? It would be a great feature to have.

@jneira
Copy link
Contributor

jneira commented Jan 15, 2021

It seems last stack version does not have a fix for this. Let me know if we can help in some way to make progress.

@qrilka
Copy link
Contributor

qrilka commented Jan 15, 2021

@jneira probably you could ask @theobat about his progress with component-based builds in #4745
I don't think there were any other moves in this direction

@theobat
Copy link
Contributor

theobat commented Jan 15, 2021

I'm making slow but steady progresses, I havn't looked at the GHCi related stuff yet. I have a component based builds branch (comp/package-refactoring) but it doesn't pass all the tests yet.

@jneira
Copy link
Contributor

jneira commented Jul 28, 2021

We got another issue about this in hls. I am afraid users are avoiding internal libraries to get projects work in the ide.

@istathar
Copy link
Contributor

We've had to just rip out a number of internal libraries in order to be able to get haskell-language-server to work. Took us a longwhile to understand why the production builds were working but a developer couldn't get anywhere locally with their IDE. I'm not hugely fussed about "internal libraries" so we're getting rid of them, but it was a head scratcher, that's for sure.

cebamps added a commit to cebamps/advent-of-code-2021 that referenced this issue Dec 6, 2021
This worked fine when working on the executables, but not on the lib
itself (which was not listed in `stack ide targets` or the target
supported in `stack build
advent-of-code-y2021:lib:advent-of-code-inputs`).

An issue is still open at the moment:
commercialhaskell/stack#4564
@majkrzak
Copy link

majkrzak commented Mar 1, 2023

Any updates on this?

@mpilgrem
Copy link
Member

Seeking to consolidate open issues, I am going to close this issue: in respect of stack ghci/repl and internal sublibraries, there is #4148 (only works after stack build); and in respect of Stack's support for public sublibraries, there is #5256 (public sublibraries) and #4745 (component-based builds).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests