Invalid value for the environment variable BUILD_PATH_PREFIX_MAP
Closed this issue · 11 comments
FATAL [ebe9e0f2]. rename C:\Users\ali\AppData\Local\Programs\DiskuvOCaml\bin\bos-6f0b13.tmp to C:\Users\ali\AppData\Local\Programs\DiskuvOCaml\bin\opam-real.exe: Permission denied
dkml-package.bc: [ERROR] FATAL [5f927a8b].
A transient failure occurred.
Root cause: The command had exit code 20:
C:\Users\ali\AppData\Local\Temp\7z5F021970\bin\dkml-install-user-runner.exe
install-user-offline-opamshim --verbosity=info --color=always
--prefix C:\Users\ali\AppData\Local\Programs\DiskuvOCaml
--staging-files C:\Users\ali\AppData\Local\Temp\7z5F021970\sg
>>> A transient failure occurred. <<<
Not sure why this keeps happening but I keep getting this permission denied on rename. I have tried deleting the DiskuvOcaml folder and reinstalling but I get the same problem.
I am running windows 11 and running this through the installer from the website
Try:
winget install Microsoft.VisualStudio.2019.BuildTools --override "--wait --passive --installPath C:\VS --addProductLang En-us --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
winget install Git.Git
if you don't have Git for Windows- Install Windows 64-bit Native Installer (unsigned)
it installed now thanks
Excellent! Re-open if you encounter any problems.
>> Fatal error: Invalid value for the environment variable BUILD_PATH_PREFIX_MAP: invalid key/value pair "C", no '=' separator
Fatal error: exception Misc.Fatal_error
This happens when I try to build the default project with dune build
Does this mean the env files were not set up properly?
I have already done this step (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
Or maybe a better question is what should the path point to? Which dir for ocaml?
If you use opam exec -- dune build
, does it work?
ok that works. Where is this located so I can add it to the path in the env variables?
You can run opam exec -- where dune
to find the exact location.
Although I'm not sure that is the problem you are facing; if you ran opam option
you should see a setenv [[PATH += ...]]
with the same location.
Edit: In fact, that looks like a dune
bug ... I don't know where it is getting BUILD_PATH_PREFIX_MAP
from, but I am guessing it is not escaping backslashes C:\...
when it is building it. Using opam exec
probably switches whatever environment variables it is reading to C:/
because opam exec
drops into Unix (MSYS2) emulation.
Should the command dune
be accessible on my terminal? Or should it always be run through opam exec
? Because dune
isnt but opam
works. There was some confusion when I used dkml init
earlier and dune
was accessible. But I reread it and I don't need the binaries in my project.
No, dune
should not be accessible in a fresh Command Prompt or PowerShell window. However, that (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
will make whatever binaries that are in your opam switch accessible ... so if dune
was in your opam switch then it would become accessible. But that dune
from your opam switch knows nothing about Visual Studio or Unix ... which is why opam exec -- dune build
works.
In earlier versions of DkML I pinned a dune.3.8.3+shim
version into the opam switch ... that "shim" let Dune know about Visual Studio and Unix. But I dropped that in DkML 2.1.0 because it was too complex:
- you couldn't upgrade
dune
if you wanted in your switch - It is much easier typing
opam exec -- dune build
compared to(& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
and thendune build
.
I'd like to get your feedback if you find opam exec -- dune build
burdensome.
I think there is another issue at play here:
- It is quite possible you have a stale
dune
in<LOCALAPPDATA>\Programs\DkMLNative\bin\dune.exe
from an earlier buggy 2.1.0 installation; if you do have those files (and you see their timestamps are quite different from the other files in that directory), please delete the olderdune.exe
anddune-real.exe
files.
Honestly not sure whats going on. So I decided to test it out again with (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
then dune build
dune build
File "bin/dune", line 3, characters 7-11:
3 | (name main)
^^^^
** Fatal error: Cannot find file "advapi32.lib"
File "caml_startup", line 1:
Error: Error during linking (exit code 2)
I get this now. I don't see dune.exe
in DKMLNative
.
I am happy to help you further debug but since opam exec
works then I don't mind just sticking with that. Thanks for the explanation because that was confusing and an update to the documentation on the ocaml site would help.
As far as feedback it is less burdensome to use this command vs the old way of doing it. Much easier to remember. But it can also be made easier than this. Following other package managers like npm
you could use the npx
command to exec stuff. I think it would be nice to have a shorthand in addition to the exec flag
so we would have both opam
and opax
is what I propose. opax dune build
should effectively be like opam exec -- dune build
. That's my two cents.
Thanks for the quick response btw I appreciate it and I am excited to learn more ocaml.
Great feedback. Thx!