utop/init.ml does not respect XDG on Windows
jonahbeckford opened this issue · 0 comments
Context
You can see in my utop session below that XDG correctly reports the configuration directory is LOCALAPPDATA, but some magic in utop
is mangling the path badly.
You can follow along with DkML 2.0.1 at https://gitlab.com/diskuv-ocaml/distributions/dkml/-/releases/2.0.1/downloads/setup64u.exe in a Windows Sandbox or a VM. Then run utop
in a Command Prompt or PowerShell.
utop # #require "utop";;
utop # let xdg = Xdg.create ~env:Sys.getenv_opt () ;;
val xdg : Xdg.t = <abstr>
utop # Xdg.config_dir xdg ;;
- : string = "C:\\Users\\WDAGUtilityAccount\\AppData\\Local"
utop # LTerm_resources.xdgbd_file ~loc:LTerm_resources.Config "utop/init.ml";;
- : string =
"C:\\Users\\WDAGUtilityAccount\\AppData\\Local\\Programs\\DiskuvOCaml\\tools\\MSYS2\\home\\WDAGUtilityAccount\\Local Settings\\utop/init.ml"
Root Cause Guess
Somehow xdgbd_file
is combining both HOME
and XDG (on Windows HOME
should either be ignored or be the fallback to LOCALAPPDATA). My guess is that something is interpreting Xdg.config_dir xdg
as a relative path (a common mistake is to assume that absolute paths have to start with a /
forward slash), and then making Xdg.config_dir xdg
an absolute path relative to $HOME
.
That means utop can't locate the correct init.ml
file:
Lines 1406 to 1417 in 5b98d28