Skip to content

Instantly share code, notes, and snippets.

@ivanperez-keera
Created September 22, 2021 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanperez-keera/e9c7a94530eac21500e1ba60e60312cd to your computer and use it in GitHub Desktop.
Save ivanperez-keera/e9c7a94530eac21500e1ba60e60312cd to your computer and use it in GitHub Desktop.
Console Log. GHC 8.10, cabal 3.4
~/tmp/du$ cabal install dunai
Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
- base-orphans-0.8.4 (lib) (requires build)
- primitive-0.7.1.0 (lib) (requires build)
- simple-affine-space-0.1.1 (lib) (requires build)
- splitmix-0.1.0.3 (lib) (requires build)
- transformers-compat-0.6.6 (lib) (requires build)
- random-1.2.0 (lib) (requires build)
- transformers-base-0.4.5.2 (lib) (requires build)
- MonadRandom-0.5.3 (lib) (requires build)
- dunai-0.7.0 (lib) (requires download & build)
Downloading dunai-0.7.0
Starting base-orphans-0.8.4 (lib)
Starting simple-affine-space-0.1.1 (lib)
Starting primitive-0.7.1.0 (lib)
Starting splitmix-0.1.0.3 (lib)
Downloaded dunai-0.7.0
Building base-orphans-0.8.4 (lib)
Building splitmix-0.1.0.3 (lib)
Building simple-affine-space-0.1.1 (lib)
Building primitive-0.7.1.0 (lib)
Installing splitmix-0.1.0.3 (lib)
Installing simple-affine-space-0.1.1 (lib)
Completed splitmix-0.1.0.3 (lib)
Starting transformers-compat-0.6.6 (lib)
Completed simple-affine-space-0.1.1 (lib)
Starting random-1.2.0 (lib)
Building transformers-compat-0.6.6 (lib)
Building random-1.2.0 (lib)
Installing base-orphans-0.8.4 (lib)
Completed base-orphans-0.8.4 (lib)
Installing transformers-compat-0.6.6 (lib)
Completed transformers-compat-0.6.6 (lib)
Starting transformers-base-0.4.5.2 (lib)
Building transformers-base-0.4.5.2 (lib)
Installing transformers-base-0.4.5.2 (lib)
Completed transformers-base-0.4.5.2 (lib)
Installing primitive-0.7.1.0 (lib)
Completed primitive-0.7.1.0 (lib)
Installing random-1.2.0 (lib)
Completed random-1.2.0 (lib)
Starting MonadRandom-0.5.3 (lib)
Building MonadRandom-0.5.3 (lib)
Installing MonadRandom-0.5.3 (lib)
Completed MonadRandom-0.5.3 (lib)
Starting dunai-0.7.0 (lib)
Building dunai-0.7.0 (lib)
Installing dunai-0.7.0 (lib)
Completed dunai-0.7.0 (lib)
Warning: installdir is not defined. Set it in your cabal config file or use
--installdir=<path>. Using default installdir: "/home/user/.cabal/bin"
Warning:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: Installation might not be completed as desired! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Without flags, the command "cabal install" doesn't expose libraries in a
usable manner. You might have wanted to run "cabal install --lib dunai".
$ cabal repl
Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
- fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Preprocessing library for fake-package-0..
Warning: No exposed modules
GHCi, version 8.10.4: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /tmp/cabal-repl.-24101/setcwd.ghci
Prelude> import Data.MonadicStreamFunction
<no location info>: error:
Could not load module ‘Data.MonadicStreamFunction’
It is a member of the hidden package ‘dunai-0.7.0’.
Perhaps you need to add ‘dunai’ to the build-depends in your .cabal file.
Prelude>
Leaving GHCi.
$ cabal install --lib dunai
Resolving dependencies...
Up to date
$ cabal repl
Resolving dependencies...
Build profile: -w ghc-8.10.4 -O1
In order, the following will be built (use -v for more details):
- fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Preprocessing library for fake-package-0..
Warning: No exposed modules
GHCi, version 8.10.4: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /tmp/cabal-repl.-24280/setcwd.ghci
Prelude> import Data.MonadicStreamFunction
<no location info>: error:
Could not load module ‘Data.MonadicStreamFunction’
It is a member of the hidden package ‘dunai-0.7.0’.
Perhaps you need to add ‘dunai’ to the build-depends in your .cabal file.
Prelude>
Leaving GHCi.
@jneira
Copy link

jneira commented Sep 22, 2021

Hi, post the logs of my tests, just in case it could help you:

D:\ws\haskell\issues\try-dunai>cabal install dunai --lib --package-env=.
Resolving dependencies...
Up to date

D:\ws\haskell\issues\try-dunai>dir
 El volumen de la unidad D es Datos
 El número de serie del volumen es: 6EEC-72D7

 Directorio de D:\ws\haskell\issues\try-dunai

22/09/2021  07:47    <DIR>          .
22/09/2021  07:47    <DIR>          ..
22/09/2021  07:47               727 .ghc.environment.x86_64-mingw32-8.10.7
               1 archivos            727 bytes
               2 dirs  92.071.018.496 bytes libres

D:\ws\haskell\issues\try-dunai>type .ghc.environment.x86_64-mingw32-8.10.7
clear-package-db
global-package-db
package-db D:\csd\ghc-8.10.7\package.db
package-id ghc-8.10.7
package-id bytestring-0.10.12.0
package-id base-4.14.3.0
package-id time-1.9.3
package-id hpc-0.6.1.0
package-id filepath-1.4.2.1
package-id process-1.6.13.2
package-id array-0.5.4.0
package-id integer-gmp-1.0.3.0
package-id containers-0.6.5.1
package-id ghc-boot-8.10.7
package-id binary-0.8.8.0
package-id ghc-prim-0.6.1
package-id ghci-8.10.7
package-id rts
package-id transformers-0.5.6.2
package-id deepseq-1.4.4.0
package-id ghc-boot-th-8.10.7
package-id pretty-1.1.3.6
package-id template-haskell-2.16.0.0
package-id directory-1.3.6.0
package-id text-1.2.4.1
package-id dunai-0.8.0-4a5a63bf929cc133cb41a92ccfdfcfda2598e6cf
D:\ws\haskell\issues\try-dunai>ghci
GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help
Loaded package environment from D:\ws\haskell\issues\try-dunai\.ghc.environment.
x86_64-mingw32-8.10.7
Prelude> import Data.MonadicStreamFunction
Prelude Data.MonadicStreamFunction> :q
Leaving GHCi.

D:\ws\haskell\issues\try-dunai>cabal repl
Resolving dependencies...
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Preprocessing library for fake-package-0..
Warning: No exposed modules
GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from C:\TEMP\cabal-repl.-2768\setcwd.ghci
Prelude> import Data.MonadicStreamFunction

<no location info>: error:
    Could not load module ‘��Data.MonadicStreamFunction’��
    It is a member of the hidden package ‘��dunai-0.8.0’��.
    Perhaps you need to add ‘��dunai’�� to the build-depends in your .cabal file
.
Prelude> :set -package dunai
package flags have changed, resetting and loading new packages...
Prelude> import Data.MonadicStreamFunction
Prelude Data.MonadicStreamFunction>

D:\ws\haskell\issues\try-dunai>cabal repl --build-depends=dunai
Resolving dependencies...
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Preprocessing library for fake-package-0..
Warning: No exposed modules
GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from C:\TEMP\cabal-repl.-12008\setcwd.ghci
Prelude> import Data.MonadicStreamFunction
Prelude Data.MonadicStreamFunction>

btw do you mind make this public?

@jneira
Copy link

jneira commented Sep 22, 2021

Using directly cabal repl --build-depends without any prior dunai build (D:\csd2 is empty)

D:\ws\haskell\issues\try-dunai2>cabal --store-dir=D:\csd2 repl --build-depends=dunai --build-log=.\build.log --index-state=HEAD
..... build of all dunai dependencies
[20 of 22] Compiling Control.Monad.Trans.MSF.Except ( src\Control\Monad\Trans\MS
F\Except.hs, dist\build\Control\Monad\Trans\MSF\Except.o )

src\Control\Monad\Trans\MSF\Except.hs:17:1: warning: [-Wunused-imports]
    The import of ‘Control.Applicative’ is redundantdant
      except perhaps to import instances from ‘Control.Applicative’
��
    To import instances alone, use: import Control.Applicative()
   |
17 | import           Control.Applicative
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[21 of 22] Compiling Control.Monad.Trans.MSF.Maybe ( src\Control\Monad\Trans\MSF
\Maybe.hs, dist\build\Control\Monad\Trans\MSF\Maybe.o )
[22 of 22] Compiling Control.Monad.Trans.MSF ( src\Control\Monad\Trans\MSF.hs, d
ist\build\Control\Monad\Trans\MSF.o )
Installing library in D:\csd2\ghc-8.10.7\incoming\new-13400\csd2\ghc-8.10.7\duna
i-0.8.0-4a5a63bf929cc133cb41a92ccfdfcfda2598e6cf\lib
Configuring library for fake-package-0..
Preprocessing library for fake-package-0..
Warning: No exposed modules
GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from C:\TEMP\cabal-repl.-13400\setcwd.ghci
Prelude> import Data.MonadicStreamFunction
Prelude Data.MonadicStreamFunction> :q
Leaving GHCi.

@ivanperez-keera
Copy link
Author

@jneira Made public!

From the second log: Did cabal modify any files at all outside of D:\csd2?

@jneira
Copy link

jneira commented Sep 22, 2021

will check, i guess $CABAL_DIR/packages will change as cabal downloads packages from hackage there. Maybe it can be changed too.

@ivanperez-keera
Copy link
Author

Thanks!

I'm not too concerned about the hackage index and the packages being downloaded. Of all things that users may want to cache, that's the most likely. I'd be ok with that one not being customizable.

@ivanperez-keera
Copy link
Author

Do you need to customize the bin dir, the share dir, data dir, etc?

@jneira
Copy link

jneira commented Sep 22, 2021

I guess so, at that point maybe it worths to create a new whole global config with cabal user-config init --config-file path/to/file and use it with --config-file
I think paths will be relative to that config file.

@ivanperez-keera
Copy link
Author

ivanperez-keera commented Sep 22, 2021

I think paths will be relative to that config file.

I'd be surprised if that were the case. It it were, that could potentially simplify things a lot.

@jneira
Copy link

jneira commented Sep 22, 2021

if they don't, we could try to set cabal_dir env var before the command

@jneira
Copy link

jneira commented Sep 23, 2021

our guess was right, user-config init uses $CABAL_DIR as base dir for config values, so changing it is needed, until it includes a new option --cabal-dir (as commented here: haskell/cabal#7455 (comment))

so

D:\ws\haskell\issues\try-dunai2>set CABAL_DIR=D:\ws\haskell\issues\try-dunai2

D:\ws\haskell\issues\try-dunai2>cabal user-config init
Writing default configuration to D:\ws\haskell\issues\try-dunai2\config
D:\ws\haskell\issues\try-dunai2>type .\config
.....
remote-repo-cache: D:\ws\haskell\issues\try-dunai2\packages
-- logs-dir: D:\ws\haskell\issues\try-dunai2\logs
world-file: D:\ws\haskell\issues\try-dunai2\world
....
extra-prog-path: D:\ws\haskell\issues\try-dunai2\bin
...
build-summary: D:\ws\haskell\issues\try-dunai2\logs\build.log
....
installdir: D:\ws\haskell\issues\try-dunai2\bin
.....
etc

After that you can do (without having to set CABAL_DIR in future sessions):

D:\ws\haskell\issues\try-dunai2>cabal --config-file=.\config update
Downloading the latest package list from hackage.haskell.org
Updated package list of hackage.haskell.org to the index-state 2021-09-23T05:14:
06Z
D:\ws\haskell\issues\try-dunai2>dir /B
config
log
packages
store

D:\ws\haskell\issues\try-dunai2>cabal --config-file=.\config repl --build-depends=dunai
Resolving dependencies...
Build profile: -w ghc-8.10.7 -O1
In order, the following will be built (use -v for more details):
 - base-orphans-0.8.5 (lib) (requires download & build)
 - primitive-0.7.2.0 (lib) (requires download & build)
 - simple-affine-space-0.1.1 (lib) (requires download & build)
 - splitmix-0.1.0.3 (lib) (requires download & build)
 - transformers-compat-0.7 (lib) (requires download & build)
 - random-1.2.1 (lib) (requires download & build)
 - transformers-base-0.4.6 (lib) (requires download & build)
 - MonadRandom-0.5.3 (lib) (requires download & build)
 - dunai-0.8.0 (lib) (requires download & build)
 - fake-package-0 (lib) (first run)
 - ............
 - 

will not touch any file in $HOME (i hope)

@jneira
Copy link

jneira commented Sep 23, 2021

@jneira
Copy link

jneira commented Sep 23, 2021

will not touch any file in $HOME (i hope)

Although i a curious about why do you want to isolate all possible dirs, did v2-build store cause you problems? Install dir can be parametrized and the build configured to use binaries produced by previous steps.
As commented the store is immutable and should build and cache new package hashed versions or reuse existing ones in a safe manner, depending on the build config. It sometimes get corrupted due to some bug, but wiping it out usually fixes it
If you want reproducible builds, pining the hackage index and use a cabal freeze file can help.

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