phoityne / ghci-dap

ghci having DAP interface.
https://hackage.haskell.org/package/ghci-dap
Other
19 stars 3 forks source link

using mixins for alternative prelude fails #12

Open newton-migosi opened 1 year ago

newton-migosi commented 1 year ago

I'm building a haskell cabal project that uses Relude as the standard library.

In the project's .cabal file, I have a mixins stanza :

mixins:
    base hiding (Prelude),
    relude (Relude as Prelude, Relude.Container.One),
    relude

When I then use the Haskell GHCi Debug Adapter VS Code plugin, I get an error from ghci-dap

Configuration read.
Starting GHCi.
Wait for a moment.
CWD: /workspace
CMD: cabal repl lib:local-library -w ghci-dap --repl-no-load --builddir=/workspace/.vscode/dist-cabal-repl -v

Now, waiting for an initial prompt("> ") from ghci.

this build was affected by the following (project) config files:
Build profile: -w ghc-9.2.7 -O1
In order, the following will be built:
 - local-library-0.1.0.0 (lib) (first run)
creating /workspace/.vscode/dist-cabal-repl/build
creating /workspace/.vscode/dist-cabal-repl/tmp
creating /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0
creating /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/cache
whenReRegister: nothing to register
Using self-exec internal setup method with build-type Simple and args:
["act-as-setup","--build-type=Simple","--","repl","--verbose=2","--builddir=/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0","--repl-no-load","lib:local-library"]
/nix/store/mm39g8n54mxvn0myxq06kaidhs1hsr53-cabal-install-3.10.1.0/bin/.cabal-wrapped
act-as-setup --build-type=Simple -- repl --verbose=2
--builddir=/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0
--repl-no-load lib:local-library
Running: /nix/store/mm39g8n54mxvn0myxq06kaidhs1hsr53-cabal-install-3.10.1.0/bin/.cabal-wrapped act-as-setup '--build-type=Simple' -- repl '--verbose=2' '--builddir=/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0' --repl-no-load 'lib:local-library'
Running: /nix/store/q2v7kijwr4blwz0cc7n1yfby3dz009kd-ghc-9.2.7-with-packages/bin/ghc-pkg init /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/package.conf.inplace
creating /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build
creating /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build/autogen
creating /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build/autogen
creating /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build/autogen
Preprocessing library for local-library-0.1.0.0..
creating /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build
Running: /nix/store/hph2sf6qi9lnpr0civ0dr250yapd0qwk-ghci-dap-0.0.20.0/bin/ghci-dap --interactive -fbuilding-cabal-package -O0 -outputdir /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build -odir /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build -hidir /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build -stubdir /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build -i -i/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build -isrc -i/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build/autogen -i/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build/global-autogen -I/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build/autogen -I/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build/global-autogen -I/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build -optP-include -optP/workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/build/autogen/cabal_macros.h -this-unit-id local-library-0.1.0.0-inplace -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /home/code/.local/state/cabal/store/ghc-9.2.7/package.db -package-db /workspace/.vscode/dist-cabal-repl/packagedb/ghc-9.2.7 -package-db /workspace/.vscode/dist-cabal-repl/build/x86_64-linux/ghc-9.2.7/local-library-0.1.0.0/package.conf.inplace -package-id 'base-4.16.4.0 (Control.Applicative, Control.Arrow, Control.Category, Control.Concurrent, Control.Concurrent.Chan, Control.Concurrent.MVar, Control.Concurrent.QSem, Control.Concurrent.QSemN, Control.Exception, Control.Exception.Base, Control.Monad, Control.Monad.Fail, Control.Monad.Fix, Control.Monad.IO.Class, Control.Monad.Instances, Control.Monad.ST, Control.Monad.ST.Lazy, Control.Monad.ST.Lazy.Safe, Control.Monad.ST.Lazy.Unsafe, Control.Monad.ST.Safe, Control.Monad.ST.Strict, Control.Monad.ST.Unsafe, Control.Monad.Zip, Data.Bifoldable, Data.Bifunctor, Data.Bitraversable, Data.Bits, Data.Bool, Data.Char, Data.Coerce, Data.Complex, Data.Data, Data.Dynamic, Data.Either, Data.Eq, Data.Fixed, Data.Foldable, Data.Function, Data.Functor, Data.Functor.Classes, Data.Functor.Compose, Data.Functor.Const, Data.Functor.Contravariant, Data.Functor.Identity, Data.Functor.Product, Data.Functor.Sum, Data.IORef, Data.Int, Data.Ix, Data.Kind, Data.List, Data.List.NonEmpty, Data.Maybe, Data.Monoid, Data.Ord, Data.Proxy, Data.Ratio, Data.STRef, Data.STRef.Lazy, Data.STRef.Strict, Data.Semigroup, Data.String, Data.Traversable, Data.Tuple, Data.Type.Bool, Data.Type.Coercion, Data.Type.Equality, Data.Type.Ord, Data.Typeable, Data.Unique, Data.Version, Data.Void, Data.Word, Debug.Trace, Foreign, Foreign.C, Foreign.C.Error, Foreign.C.String, Foreign.C.Types, Foreign.Concurrent, Foreign.ForeignPtr, Foreign.ForeignPtr.Safe, Foreign.ForeignPtr.Unsafe, Foreign.Marshal, Foreign.Marshal.Alloc, Foreign.Marshal.Array, Foreign.Marshal.Error, Foreign.Marshal.Pool, Foreign.Marshal.Safe, Foreign.Marshal.Unsafe, Foreign.Marshal.Utils, Foreign.Ptr, Foreign.Safe, Foreign.StablePtr, Foreign.Storable, GHC.Arr, GHC.Base, GHC.Bits, GHC.ByteOrder, GHC.Char, GHC.Clock, GHC.Conc, GHC.Conc.IO, GHC.Conc.Signal, GHC.Conc.Sync, GHC.ConsoleHandler, GHC.Constants, GHC.Desugar, GHC.Enum, GHC.Environment, GHC.Err, GHC.Event, GHC.Event.TimeOut, GHC.Exception, GHC.Exception.Type, GHC.ExecutionStack, GHC.ExecutionStack.Internal, GHC.Exts, GHC.Fingerprint, GHC.Fingerprint.Type, GHC.Float, GHC.Float.ConversionUtils, GHC.Float.RealFracMethods, GHC.Foreign, GHC.ForeignPtr, GHC.GHCi, GHC.GHCi.Helpers, GHC.Generics, GHC.IO, GHC.IO.Buffer, GHC.IO.BufferedIO, GHC.IO.Device, GHC.IO.Encoding, GHC.IO.Encoding.CodePage, GHC.IO.Encoding.Failure, GHC.IO.Encoding.Iconv, GHC.IO.Encoding.Latin1, GHC.IO.Encoding.Types, GHC.IO.Encoding.UTF16, GHC.IO.Encoding.UTF32, GHC.IO.Encoding.UTF8, GHC.IO.Exception, GHC.IO.FD, GHC.IO.Handle, GHC.IO.Handle.FD, GHC.IO.Handle.Internals, GHC.IO.Handle.Lock, GHC.IO.Handle.Text, GHC.IO.Handle.Types, GHC.IO.IOMode, GHC.IO.StdHandles, GHC.IO.SubSystem, GHC.IO.Unsafe, GHC.IOArray, GHC.IOPort, GHC.IORef, GHC.Int, GHC.Integer, GHC.Integer.Logarithms, GHC.Ix, GHC.List, GHC.MVar, GHC.Maybe, GHC.Natural, GHC.Num, GHC.Num.BigNat, GHC.Num.Integer, GHC.Num.Natural, GHC.OldList, GHC.OverloadedLabels, GHC.Pack, GHC.Profiling, GHC.Ptr, GHC.RTS.Flags, GHC.Read, GHC.Real, GHC.Records, GHC.ResponseFile, GHC.ST, GHC.STRef, GHC.Show, GHC.Stable, GHC.StableName, GHC.Stack, GHC.Stack.CCS, GHC.Stack.Types, GHC.StaticPtr, GHC.Stats, GHC.Storable, GHC.TopHandler, GHC.TypeLits, GHC.TypeLits.Internal, GHC.TypeNats, GHC.TypeNats.Internal, GHC.Unicode, GHC.Weak, GHC.Word, Numeric, Numeric.Natural, System.CPUTime, System.Console.GetOpt, System.Environment, System.Environment.Blank, System.Exit, System.IO, System.IO.Error, System.IO.Unsafe, System.Info, System.Mem, System.Mem.StableName, System.Mem.Weak, System.Posix.Internals, System.Posix.Types, System.Timeout, Text.ParserCombinators.ReadP, Text.ParserCombinators.ReadPrec, Text.Printf, Text.Read, Text.Read.Lex, Text.Show, Text.Show.Functions, Type.Reflection, Type.Reflection.Unsafe, Unsafe.Coerce)' -package-id 'relude-1.1.0.0-B6zcHDYI1P31kfRGCmdMyN (Relude as Prelude, Relude.Container.One)' -package-id relude-1.1.0.0-B6zcHDYI1P31kfRGCmdMyN -package-id aeson-2.0.3.0-E1Z0tCMH7LG1C85dTvi65b -package-id async-2.2.4-4hewjgHC8JJEf9gl0RbqkV -package-id beam-core-0.9.2.1-K8Qh3pynzaiAbDP7iybWtp -package-id beam-migrate-0.5.1.2-8hIrHFtz9GjE3xv5OYfRwz -package-id beam-postgres-0.5.2.1-2OmE4AgBZZdCZyKRu0AL0s -package-id blaze-html-0.9.1.2-BkR3GiYXrrV13D0VszY94A -package-id cassava-0.5.3.0-2ZHasGLBVRLJL0WAKWawQi -package-id conduit-1.3.4.3-5blWhtQ3BTS4N9Us6TxFxJ -package-id data-default-0.7.1.1-JljmhNSdFHDL8LUWBWCV1e -package-id directory-1.3.6.2 -package-id exceptions-0.10.4 -package-id fast-logger-3.1.2-HuPsttmhxMPJHZoaOhGc1P -package-id filepath-1.4.2.2 -package-id generic-lens-2.2.1.0-L7L7kXpKOjcEO05ALWqmAH -package-id hs-opentelemetry-api-0.0.3.6-Lh9GCRB64PVEIam62sr9Wi -package-id http-client-0.7.13.1-LD6phKgeaaB2pE4kDnhU46 -package-id http-types-0.12.3-5oPb87Y9mmT2cli2uNSI69 -package-id linear-base-0.3.1-5rfo9gH9ToyCtieJMAJMDo -package-id monad-logger-0.3.39-JqwR4XyfP6DDk4nqD48PfS -package-id mtl-2.2.2 -package-id optics-core-0.4.1-4r1bYmt53v96GsUSz861mz -package-id optics-th-0.4.1-9e84KfRCIhN3OMRqJQWGmE -package-id prettyprinter-1.7.1-HrDU9aNhok13fjOTXkGJhy -package-id profunctors-5.6.2-28W6WTT1AzNEExqBOSGSNs -package-id resource-pool-0.2.3.2-51Ethz7yeJqKh0qeAptG82 -package-id resourcet-1.2.6-JS79KQRrH9P1h5FgIhYZFP -package-id servant-auth-0.4.1.0-F7kYXWaZ0YOC40E0YeVpXv -package-id servant-auth-client-0.4.1.0-AIO6AWRXvbM7ncSkUAnbGW -package-id servant-auth-server-0.4.7.0-Cq9eIIOD6NNBByq20x3kxG -package-id servant-auth-swagger-0.2.10.1-77OaZLeJvMZ52at2Bn3KE8 -package-id servant-blaze-0.9.1-6cuNAeu6EGKJSDlJpMr1LN -package-id servant-cassava-0.10.2-4QySMxm4FMe6Jga9VsDR9P -package-id servant-client-0.19-84mSTwIgf3yCYqdewPXKdn -package-id servant-conduit-0.15.1-5FGQCfG8HIYJxwg53rJWSQ -package-id servant-multipart-0.12.1-IfFQExrnEyexgVzH1jP7p -package-id servant-multipart-api-0.12.1-2vjy9CRgSuN6fdbYPlN0h0 -package-id servant-multipart-client-0.12.1-KtZbL5qXXdFJSckljtxtH3 -package-id servant-serialization-0.2.1-8vw9c2nqfMlGizRLJRU2lG -package-id servant-server-0.19.2-BXLflmxfJOwIyBH9ESfx1C -package-id servant-swagger-1.1.11-IvuTwwcbBKN1SpfyvCQFJT -package-id servant-swagger-ui-0.3.5.4.5.0-B2GTvufylC78lTrEmVKr6M -package-id shower-0.2.0.3-GvfKuHv4xBsAUlQAcBB9V6 -package-id swagger2-2.8.6-ECczarnX5nFKKqKyuHiUB1 -package-id time-1.11.1.1 -package-id wai-3.2.3-Ig9tz4vaOPq7YSPCUKI8Mv -package-id warp-3.3.23-K4FNB0SGWzy8OXjax2ezr7 -package-id with-utf8-1.0.2.3-5PXESi3Jm7c9uwrAgRH4SD -XHaskell2010 -XNoFieldSelectors -XNoStarIsType -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveAnyClass -XDeriveDataTypeable -XDeriveFoldable -XDeriveFunctor -XDeriveGeneric -XDeriveLift -XDeriveTraversable -XDerivingStrategies -XDerivingVia -XDuplicateRecordFields -XEmptyCase -XEmptyDataDecls -XEmptyDataDeriving -XExistentialQuantification -XExplicitForAll -XFlexibleContexts -XFlexibleInstances -XGADTSyntax -XGeneralisedNewtypeDeriving -XImportQualifiedPost -XKindSignatures -XLambdaCase -XLinearTypes -XMultiParamTypeClasses -XMultiWayIf -XNumericUnderscores -XOverloadedLabels -XOverloadedStrings -XPolyKinds -XPostfixOperators -XRankNTypes -XScopedTypeVariables -XStandaloneDeriving -XStandaloneKindSignatures -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators -XUnicodeSyntax -XViewPatterns -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-deriving-strategies -Wunused-foralls -Wunused-foralls -fprint-explicit-foralls -fprint-explicit-kinds -hide-all-packages
[DAP][INFO] start ghci-dap-0.0.20.0.
GHCi, version 9.2.7: https://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package-id relude-1.1.0.0-B6zcHDYI1P31kfRGCmdMyN (Relude as Prelude, Relude.Container.One)
    (use -v for more information)
CallStack (from HasCallStack):
  withMetadata, called at src/Distribution/Simple/Utils.hs:368:14 in Cabal-3.10.1.0-5sSVeMY5t4HKsrW2wqIvsr:Distribution.Simple.Utils
Error: cabal: repl failed for local-library-0.1.0.0-inplace.

invalid HANDLE. eof.

I followed the plugin's default config which executes ghci-dap via

cabal repl -w ghci-dap --repl-no-load --builddir=${workspaceFolder}/.vscode/dist-cabal-repl

My setup is VS Code using a dev-container from https://github.com/xtruder/nix-devcontainer that provisions nix and all the nix derived tools including ghci-dap. I have in my flake.nix

{# See https://github.com/srid/haskell-flake/blob/master/example/flake.nix
        haskellProjects.default = {
          # packages.local-library.root = ./.; # Auto-discovered by haskell-flake
          overrides = self: super: { };
          devShell = {
            tools = hp: {
              inherit (hp) haskell-debug-adapter ghci-dap;
              treefmt = config.treefmt.build.wrapper;
            } // config.treefmt.build.programs;
            hlsCheck.enable = true;
          };
          autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
        };
}

Package versions

$ cabal --version
cabal-install version 3.10.1.0
compiled using version 3.10.1.0 of the Cabal library

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.2.7

$ ghci-dap --version
[DAP][INFO] start ghci-dap-0.0.20.0.
The Glorious Glasgow Haskell Compilation System, version 9.2.7
phoityne commented 1 year ago

Hi.

I followed the plugin's default config which executes ghci-dap via

cabal repl -w ghci-dap --repl-no-load --builddir=${workspaceFolder}/.vscode/dist-cabal-repl
(no  "lib:local-library" option.)

Could you confirm the cabal command ?

From console log, seems that you ran the command with "lib:local-library" option.

CMD: cabal repl lib:local-library -w ghci-dap --repl-no-load --builddir=/workspace/.vscode/dist-cabal-repl -v
newton-migosi commented 1 year ago

I added lib:local-library to the command because the project has multiple libraries, so the command I ran was

cabal repl lib:local-library -w ghci-dap --repl-no-load --builddir=/workspace/.vscode/dist-cabal-repl -v
phoityne commented 1 year ago

I could not reproduce this issue in my environment. CentOS, your haskell-template project.

Could you try running command from the terminal ? with ghci-dap, and without ghci-dap.

$ cd /to/project/directory
$
$ cabal repl lib:local-library -w ghci-dap --repl-no-load --builddir=/workspace/.vscode/dist-cabal-repl -v
$
$ cabal repl lib:local-library --repl-no-load --builddir=/workspace/.vscode/dist-cabal-repl -v
$

getting same result ?

Regards.

newton-migosi commented 1 year ago

Here's the logs I get when using ghci-dap: https://gist.githubusercontent.com/newton-migosi/40372053427d5cfdc34401a57130cd50/raw/da98924c64664ac1f13350c0a23b702c8f7fc7d0/cabal-repl-ghci-dap.log.txt

Here's the logs without using ghci-dap: https://gist.githubusercontent.com/newton-migosi/40372053427d5cfdc34401a57130cd50/raw/da98924c64664ac1f13350c0a23b702c8f7fc7d0/cabal-repl-no-ghci-dap.log.txt

Executing cabal repl without ghci-dap works and starts a ghci session, using ghci-dap fails with error logs:https://gist.githubusercontent.com/newton-migosi/40372053427d5cfdc34401a57130cd50/raw/da98924c64664ac1f13350c0a23b702c8f7fc7d0/cabal-repl-ghci-dap.errors.log.txt

The project I'm building is based off the haskell-template but I've pushed the changes to github at https://github.com/newton-migosi/mdn-local-library-tutorial/commit/b5be4eee5cc5f1f459368d69758a45678bb54f94 .. I'd written it to use docker to provision nix but I figure a direct nix develop should provide a shell similar to what I'm working with

krupalhp2907 commented 1 year ago

@phoityne I am facing the same issue. @newton-migosi did you find any resolution for this?

phoityne commented 1 year ago

Hi.

I reproduced this issue.(centos9 + nix + haskell-template repo) Adding package-db option, it would work.

e.g.)

cabal repl -w ghci-dap --builddir=/work/haskell/haskell-template/.vscode/dist-cabal-repl --package-db=/nix/store/w1ycwrniik4bvzxj9849d5inz6j3x558-ghc-9.2.7-with-packa
ges/lib/ghc-9.2.7/package.conf.d/

relude package is included in ghc itself.

Regards.

krupalhp2907 commented 1 year ago

Hi, thanks for the reply @phoityne

package-db flag/GHC_PACKAGE_PATH seems not to be working in my case, for now I have to manually added the package.conf.d path in code itself However, it fixed the error but later while debugging getting

` packages definitely up to date: packages previously probably up to date: packages now probably up to date: packages newly up to date: packages out to date: project-0.0.1.19-project-lib, project-0.0.1.19-project-lib, project-0.0.1.19-inplace-hspec packages invalid due to dep change: project-0.0.1.19-inplace-project, project-0.0.1.19-inplace-project-lib, project-0.0.1.19-inplace-hspec packages invalid due to build failure: project-0.0.1.19-inplace-project-lib

cabal: repl failed for project-0.0.1.19-inplace-project-lib. The build process segfaulted (i.e. SIGSEGV). `

I have tried debugging without ghci-dap and it's working just fine. any suggestions, what might have caused this issue?

phoityne commented 1 year ago

Could you show full console log ?

e.g.)

$ cabal repl -v -w ghci-dap --builddir=/work/haskell/haskell-template/.vscode/dist-cabal-repl --package-db=/nix/store/w1ycwrniik4bvzxj9849d5inz6j3x558-ghc-9.2.7-with-packa
ges/lib/ghc-9.2.7/package.conf.d/
ghci> :l app/Main.hs
ghci> main