Elixir on windows HOMEDRIVE issue

When I run the Erlang or IEX on windows, while not connect to my work vpn
I get this error

PS C:\Users\myusernameredacted> iex.bat
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

=ERROR REPORT==== 29-Sep-2024::22:02:42.488000 ===
file:path_eval(["H:\\","c:/Users/myusernameredacted/AppData/Roaming/erlang"],".erlang"): no such device or address

Interactive Elixir (1.17.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>

This same issue seem to ompaces ElixirLS plugin on VS Code on windows, the language server fail to start and raise this error

Mix.install failed with ** (File.Error) could not make directory (with -p) "h:/.mix/archives/hex-2.1.1

Now H: is set as my home drive

PS C:\Users\myusernameredacted> $env:HOMEDRIVE
H:

Erlang and by consequence Elixir and Elixir tools, seem to try to store some configuration files in the HOMEDRIVE, and when it doesn’t find it raise the error

Now also note that the folder "c:/Users/myusernameredacted/AppData/Roaming/erlang"
exist, I dont know why its part of the error, I assumed that if Elarng doesnt find H: it would try "c:/Users/myusernameredacted/AppData/Roaming/erlang" , but this doesnt seem to be the case, since the folder exist and I still get the error

This is my work computer, so i cannot reconfigure my HOMEDRIVE which is set to a network drive only available when I am connected to the work vpn

Also if this help, I used to get a similar issue with git, where it used to look for gitconfig exclusively in the HOMEDRIVE, but git provide the possibility to set the environment variable GIT_CONFIG_GLOBAL

Now the iex.bat complains, but works or seem to work, ElixirLs plugin, fails and doesnt load, so this is a bigger issue for the vs code plugin

How can I tell Erlang and Elixir to use a different folder if it fails to find my home drive?
Googling suggest, there is no fix, and issue was raised mainly by RabbitMQ users, so I am not very optimistic, but if anyone knows a fix or a workaround please share it

–edit–
I would like to add that temporarily changing my HOMEDRIVE works, I didnt try to permanently change it, since this is not my personal computer
so running this command on powershell before starting vs code or iex from the same shell works

$env:HOMEDRIVE = 'C:\home\'

I don’t use windows, but does your myusernameredacted perhaps contain a space?

Nope
No spaces in my user name

I wonder why, the fall back option didnt work
I checked the Erlang docs for file:path_eval

path_eval(Path, Filename)

Searches the path Path (a list of directory names) until the file Filename is found. If Filename is an absolute filename, Path is ignored. Then reads and evaluates Erlang expressions, separated by . (or ,, a sequence of expressions is also an expression), from the file. The result of evaluation is not returned; any expression sequence in the file must be there for its side effect.

Whey didnt the tools just use c:/Users/myusernameredacted/AppData/Roaming/erlang
when they failed to find H:/

Have you tried setting the MIX_HOME and HEX_HOME environment variables?

Thanks
This seem to fix it

:+1:

That out of the way, is there a best practice of where to point MIX_HOME and HEX_HOME

There’s not any that I’m aware of. I would prioritize putting setting them to a location that:

  • is always available (so not something accessed over the network)
  • With plenty of available storage space
1 Like

And permanent, not a temporary folder

1 Like