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

stack ghci ignores common mixins #5570

Closed
agluszak opened this issue Jun 28, 2021 · 1 comment
Closed

stack ghci ignores common mixins #5570

agluszak opened this issue Jun 28, 2021 · 1 comment

Comments

@agluszak
Copy link

General summary/comments (optional)

Background: I wanted to contribute to Stan (https://github.com/kowainik/stan) and use VS code with HLS to code. HLS kept reporting some strange errors. I found out that the problem might be related to hie-bios. In its readme I read:
If you find that hie-bios can't load a certain component or file, run stack repl and stack repl <component name> to see if stack succeeds in building your project. Chances are that there is a problem in your project and if you fix that, hie-bios will succeed to load it.
So I tried to run stack repl,

but it failed
agluszak@devmachina:~/code/zpf/stan$ stack repl
Using main module: 1. Package `stan' component stan:exe:stan with main-is file: /home/agluszak/code/zpf/stan/app/Main.hs
Building all executables for `stan' once. After a successful build of all of them, only specified executables will be rebuilt.
stan> configure (lib + internal-lib + exe)
Configuring stan-0.0.1.0...
stan> initial-build-steps (lib + internal-lib + exe)
Configuring GHCi with the following packages: stan
GHCi, version 8.10.3: https://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package z-stan-z-target
    (use -v for more information)

It looks like it's a separate issue though (#4148),

because after running `stack build`
agluszak@devmachina:~/code/zpf/stan$ stack build
Building all executables for `stan' once. After a successful build of all of them, only specified executables will be rebuilt.
stan> configure (lib + internal-lib + exe)
Configuring stan-0.0.1.0...
stan> build (lib + internal-lib + exe)
Preprocessing library for stan-0.0.1.0..
Building library for stan-0.0.1.0..
[ 1 of 43] Compiling Paths_stan
[ 2 of 43] Compiling Stan.Browse
[ 3 of 43] Compiling Stan.Category
[ 4 of 43] Compiling Stan.Core.Id
[ 5 of 43] Compiling Stan.Core.List
[ 6 of 43] Compiling Stan.EnvVars
[ 7 of 43] Compiling Stan.Example
[ 8 of 43] Compiling Stan.Ghc.Compat
[ 9 of 43] Compiling Stan.Core.ModuleName
[10 of 43] Compiling Stan.Hie.Compat
[11 of 43] Compiling Stan.Cabal
[12 of 43] Compiling Stan.Info
[13 of 43] Compiling Stan.NameMeta
[14 of 43] Compiling Stan.Hie.Debug
[15 of 43] Compiling Stan.Pattern.Edsl
[16 of 43] Compiling Stan.Pattern.Type
[17 of 43] Compiling Stan.Pattern.Ast
[18 of 43] Compiling Stan.Hie
[19 of 43] Compiling Stan.Hie.MatchType
[20 of 43] Compiling Stan.Hie.MatchAst
[21 of 43] Compiling Stan.Report.Css
[22 of 43] Compiling Stan.Report.Settings
[23 of 43] Compiling Stan.Severity
[24 of 43] Compiling Stan.Inspection
[25 of 43] Compiling Stan.Inspection.Style
[26 of 43] Compiling Stan.Inspection.Partial
[27 of 43] Compiling Stan.Inspection.Infinite
[28 of 43] Compiling Stan.Inspection.AntiPattern
[29 of 43] Compiling Stan.Inspection.All
[30 of 43] Compiling Stan.Observation
[31 of 43] Compiling Stan.FileInfo
[32 of 43] Compiling Stan.Analysis.Visitor
[33 of 43] Compiling Stan.Analysis.Analyser
[34 of 43] Compiling Stan.Analysis
[35 of 43] Compiling Stan.Analysis.Pretty
[36 of 43] Compiling Stan.Config
[37 of 43] Compiling Stan.Config.Pretty
[38 of 43] Compiling Stan.Cli
[39 of 43] Compiling Stan.Analysis.Summary
[40 of 43] Compiling Stan.Report.Html
[41 of 43] Compiling Stan.Report
[42 of 43] Compiling Stan.Toml
[43 of 43] Compiling Stan
Preprocessing library 'target' for stan-0.0.1.0..
Building library 'target' for stan-0.0.1.0..
[1 of 9] Compiling Target.AntiPattern
[2 of 9] Compiling Target.AntiPattern.Stan0206
[3 of 9] Compiling Target.AntiPattern.Stan0206Extensions
[4 of 9] Compiling Target.AntiPattern.Stan0212
[5 of 9] Compiling Target.AntiPattern.Stan0213
[6 of 9] Compiling Target.AntiPattern.Stan0214
[7 of 9] Compiling Target.Infinite
[8 of 9] Compiling Target.Partial
[9 of 9] Compiling Target.Style
Preprocessing executable 'stan' for stan-0.0.1.0..
Building executable 'stan' for stan-0.0.1.0..
[1 of 1] Compiling Main
Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/stan/stan ...
stan> copy/register
Installing library in /home/agluszak/code/zpf/stan/.stack-work/install/x86_64-linux-tinfo6/ecbe5bfaab41fbab1a17b841cfb6656a9017f8b8f433567e0dc2d7fdf99764d9/8.10.3/lib/x86_64-linux-ghc-8.10.3/stan-0.0.1.0-eYx0U2wni4Juz5Jiygr4h
Installing internal library target in /home/agluszak/code/zpf/stan/.stack-work/install/x86_64-linux-tinfo6/ecbe5bfaab41fbab1a17b841cfb6656a9017f8b8f433567e0dc2d7fdf99764d9/8.10.3/lib/x86_64-linux-ghc-8.10.3/stan-0.0.1.0-FIrEVBBAmGTCbmEQS6vdWO-target
Installing executable stan in /home/agluszak/code/zpf/stan/.stack-work/install/x86_64-linux-tinfo6/ecbe5bfaab41fbab1a17b841cfb6656a9017f8b8f433567e0dc2d7fdf99764d9/8.10.3/bin
Registering library for stan-0.0.1.0..
Registering library 'target' for stan-0.0.1.0..
it failed with a different error:
agluszak@devmachina:~/code/zpf/stan$ stack repl
Using main module: 1. Package `stan' component stan:exe:stan with main-is file: /home/agluszak/code/zpf/stan/app/Main.hs
Configuring GHCi with the following packages: stan
GHCi, version 8.10.3: https://www.haskell.org/ghc/  :? for help
[ 1 of 53] Compiling Paths_stan
[ 2 of 53] Compiling Stan.Browse

/home/agluszak/code/zpf/stan/src/Stan/Browse.hs:46:75: error:
    Variable not in scope: toText :: String -> Data.Text.Internal.Text
   |
46 |                     errorMessage $ "Cannot guess browser for the OS: " <> toText curOs
   |                                                                           ^^^^^^

/home/agluszak/code/zpf/stan/src/Stan/Browse.hs:48:21: error:
    Variable not in scope: exitFailure :: IO ()
   |
48 |                     exitFailure
   |                     ^^^^^^^^^^^

<no location info>: warning: [-Wunused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - unordered-containers-0.2.13.0
      - trial-tomland-0.0.0.0
      - trial-optparse-applicative-0.0.0.0
      - trial-0.0.0.0
      - tomland-1.3.1.0
      - slist-0.1.1.0
      - pretty-simple-4.0.0.0
      - optparse-applicative-0.15.1.0
      - microaeson-0.1.0.0
      - gitrev-1.3.1
      - ghc-boot-th-8.10.3
      - ghc-8.10.3
      - filepath-1.4.2.1
      - extensions-0.0.0.1
      - dir-traverse-0.2.2.3
      - cryptohash-sha1-0.11.100.1
      - containers-0.6.2.1
      - clay-0.13.3
      - blaze-html-0.9.1.2
      - base64-0.4.2.2
      - array-0.5.4.0
      - relude-0.7.0.0
      - stan-0.0.1.0
Failed, one module loaded.

<no location info>: error:
    Could not load module ‘Stan’
    It is a member of the hidden package ‘stan-0.0.1.0’.
    You can run ‘:set -package stan’ to expose it.
    (Note: this unloads all the modules in the current scope.)
Loaded GHCi configuration from /tmp/haskell-stack-ghci/958d3ea1/ghci-script
*Paths_stan> 
Leaving GHCi.

Now the errors reported by stack repl for file Browse.hs were exactly the same as those reported by HLS.
Stan depends on relude, which provides these two missing symbols: toText :: String -> Data.Text.Internal.Text and exitFailure :: IO ().

Relude is depended upon using the mixin functionality (see: https://github.com/kowainik/stan/blob/main/stan.cabal#L69), but it looks like it is ignored when you run stack ghci / stack repl.

Steps to reproduce

  1. git clone [email protected]:kowainik/stan.git
  2. cd stan
  3. stack build
  4. stack ghci

Expected

The build succeeds.

Actual

It fails with the message above.

Stack version

$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4

Method of installation

  • Official binary, downloaded from stackage.org or fpcomplete's package repository
@mpilgrem
Copy link
Member

mpilgrem commented Apr 2, 2024

This appears to me to be a duplicate of #5077.

@mpilgrem mpilgrem closed this as completed Apr 2, 2024
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

2 participants