Running Elixir application on Ubuntu inside Windows? Ubuntu says it "could not touch" the beam file generated on trying to run project?

I installed Ubuntu on Windows for Elixir development as some of the packages I need are not Windows compatible. So I need to test/run my existing Phoenix/Elixir project from inside this Ubuntu command line.

I got Elixir/Erlang/Phoenix installed okay, but when I navigate to an existing directory where I have a project like cd /mnt/h/users/mike/documents/testserver/ and run iex -S mix phx.server I get:

==> file_system
Compiling 7 files (.ex)
** (EXIT from #PID<0.99.0>) an exception was raised:
    ** (File.Error) could not touch "/mnt/h/users/mike/documents/testserver/_build/dev/lib/file_system/ebin/Elixir.FileSystem.beam": not owner
        (elixir 1.16.0) lib/file.ex:631: File.touch!/2
        (elixir 1.16.0) lib/kernel/parallel_compiler.ex:334: anonymous fn/3 in Kernel.ParallelCompiler.write_module_binaries/3
        (elixir 1.16.0) lib/enum.ex:1264: anonymous fn/3 in Enum.flat_map/2
        (stdlib 5.2) maps.erl:416: :maps.fold_1/4
        (elixir 1.16.0) lib/enum.ex:2540: Enum.flat_map/2
        (elixir 1.16.0) lib/kernel/parallel_compiler.ex:260: Kernel.ParallelCompiler.spawn_workers/3
        (mix 1.16.0) lib/mix/compilers/elixir.ex:1002: anonymous fn/9 in Mix.Compilers.Elixir.compiler_loop/6

Do you know what this might represent?

I tried deleting the _build folder and letting it make it again but it just creates a new _build folder with only Elixir.FileSystem.beam and fails after that same error.

Is there some trick to running this setup I’m missing in terms of file access on Ubuntu on Windows?

If I try to access the project like nano mix.exs I can edit the file and save so I do have permissions but the Elixir build is not running.

elixir -v gives Erlang/OTP 26 & Elixir 1.16.0 which seems to be as expected.

Thanks for any help.

Found the missing trick. When you install Ubuntu on Windows it makes you create a new username and password, but when you check chown all your files are owned by root (which will not be who you will be auto set up as.

You need to follow the instructions here:

Basically, close the Ubuntu down and from an elevated command prompt run ubuntu config --default-user root then restart your Ubuntu and you will be in as root with normal ability to do anything after that.

Though you will have to reinstall elixir/erlang again.

Leaving this as a solution in case anyone else finds it.

1 Like