How to install modules (II)

Hello everyone.
I am a newbie in Haskell and am trying to install the random module following the advice in reply to Javier Moreno on August 28th. It ends badly:

Blockquote

ghc.exe: can’t find a package database at C:\Users\Jean-François.Asus\AppData\Roaming\cabal\store\ghc-8.10.1\package.db

Blockquote

In details:

cabal --version
cabal --version
Process started (PID=9520) >>>
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library
<<< Process finished (PID=9520). (Exit code 0)
================ READY ================

cabal install --lib --package-env . random
cabal install --lib --package-env . random
Process started (PID=7332) >>>
Resolving dependencies…
Up to date
<<< Process finished (PID=7332). (Exit code 0)
================ READY ================
dir
DIR: *

.ipynb_checkpoints .pytest_cache __pycache__

.ghc.environment.x86_64-mingw32-8.10.1

random2.hs
================ READY ================

ghci
ghci
Process started (PID=6912) >>>
GHCi, version 8.10.1: https://www.haskell.org/ghc/ :? for help
Loaded package environment from C:\Users\Jean-Fran‡ois.Asus\Documents\MEGAsync\Logique.ghc.environment.x86_64-mingw32-8.10.1
ghc.exe: can’t find a package database at C:\Users\Jean-François.Asus\AppData\Roaming\cabal\store\ghc-8.10.1\package.db
<<< Process finished (PID=6912). (Exit code 1)
================ READY ================

Thank you for your help!

Does this path exist in your system?

C:\Users\Jean-François.Asus\AppData\Roaming\cabal\store\ghc-8.10.1\package.db

Thanks for your help!.
Yes the path exist with
package.cache
package.cache.lock
random-1.2.0-92da20898bbd7b5908a48cf973b38929eb0f9846.conf
random-1.2.0-e749353bf0a5b8cc14fdcfff80e20283814d794d.conf
splitmix-0.1.0.1-8bacb038ae1d7b2760bf8be918f960a5abfc44e8.conf
splitmix-0.1.0.1-ea59d7a4a9608f0fda3610913add6392c93aa477.conf

by the way, could the cedilla in the filename be a problem?
Thanks again.

Could be, although creating a whole new user to test that hypothesis might be inconvenient.

If danidiaz’s hypothesis is correct, I guess temporarily modifying LOCALAPPDATA with a bat file below would help you.

Save the the file named cabal.bat like below:

@echo off
set LOCALAPPDATA=C:\some\other\path\only\containing\ascii\
C:\path\to\actual\cabal.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

Then try .\cabal.bat install.

Make sure all related paths don’t contain any non-ascii characters.
I (and perhaps danidiaz) suspect this is caused by the non-ascii characters in the path (specifically “ç” of “Jean-François.Asus”).

Thank you for these tips, I try the maneuver…

Thanks again.
I tried with

@echo off
set LOCALAPPDATA=C:\utilisateurs\public\essaihaskell
C:\path\programdata\chocolatey\bin\cabal.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

But it didn’t work:

================ READY ================
dir
DIR: *
cabal.bat
random2.hs
================ READY ================
cabal update
cabal update
Process started (PID=4996) >>>
Downloading the latest package list from hackage.haskell.org
To revert to previous state run:
cabal v2-update ‘hackage.haskell.org,2020-09-10T07:32:49Z’
<<< Process finished (PID=4996). (Exit code 0)
================ READY ================
cabal install random
cabal install random
Process started (PID=8748) >>>
Resolving dependencies…
Up to date
Warning: You asked to install executables, but there are no executables in
target: random. Perhaps you want to use --lib to install libraries instead.
<<< Process finished (PID=8748). (Exit code 0)
================ READY ================
dir
DIR: *
cabal.bat
random2.hs
================ READY ================
cabal --lib install random
cabal --lib install random
Process started (PID=6560) >>>
Resolving dependencies…
Up to date
<<< Process finished (PID=6560). (Exit code 0)
================ READY ================
dir
DIR: *
cabal.bat
random2.hs
================ READY ================

Even if the error is not the same, a file with a strange name is missing

Thanks for your help

I think you forgot the --package-env . flag. Without that it uses the default environment which is stored somewhere else.

So the full command is: cabal install --lib --package-env . random.

Thanks again!

this time I have the oddly named file, but the database search is still in the wrong directory.

cabal install --lib --package-env . random
cabal install --lib --package-env . random
Process started (PID=6368) >>>
Resolving dependencies…
Up to date
<<< Process finished (PID=6368). (Exit code 0)
================ READY ================
dir
DIR: *
.ghc.environment.x86_64-mingw32-8.10.1
cabal.bat
installation.txt
random2.hs
================ READY ================
GHCi
GHCi
Process started (PID=1428) >>>
GHCi, version 8.10.1: https://www.haskell.org/ghc/ :? for help
Loaded package environment from C:\Users\Public\EssaiHaskell.ghc.environment.x86_64-mingw32-8.10.1
ghc.exe: can’t find a package database at C:\Users\Jean-François.Asus\AppData\Roaming\cabal\store\ghc-8.10.1\package.db
<<< Process finished (PID=1428). (Exit code 1)

Thanks for your help

You can try changing the CABAL_DIR environment variable to change the location of the .cabal folder and therefore also the .cabal\store\ghc-...\package.db.

Hmm …
I don’t understand correctly: should I edit the “config” file by hand? But “config” is in a subdirectory of a directory with a cedilla in the name.

The forums talk about “sandbox”, would it be possible to create one in a specific directory of a specific windows user without having to uninstall and reinstall GHC, CABAL …?

Thanks again for your help

I’m not very familiar with cabal on windows. But, I think you can set the CABAL_DIR environment variable via Windows itself. I found this guide about environment variables on Windows after a quick search. I think creating a new environment variable with the name CABAL_DIR and a value C:\Users\Public\cabal might work.

Thanks for the ref. I read this carefully