(File.Error) could not remove files and directories recursively from "c:/apps/my_app/_build/dev/lib/argon2_elixir": not owner

I frequently get this error during compilation. The only solution I’ve found is to manually delete the _build folder.

Full stack trace:

** (File.Error) could not remove files and directories recursively from "c:/apps/my_app/_build/dev/lib/argon2_elixir": not owner
    (elixir 1.11.2) lib/file.ex:1290: File.rm_rf!/1
    (mix 1.11.2) lib/mix/tasks/deps.compile.ex:81: anonymous fn/4 in Mix.Tasks.Deps.Compile.compile/2
    (elixir 1.11.2) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.11.2) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    (mix 1.11.2) lib/mix/tasks/deps.compile.ex:79: Mix.Tasks.Deps.Compile.compile/2
    (mix 1.11.2) lib/mix/tasks/deps.loadpaths.ex:89: Mix.Tasks.Deps.Loadpaths.deps_check/2
    (mix 1.11.2) lib/mix/tasks/deps.loadpaths.ex:28: Mix.Tasks.Deps.Loadpaths.run/1
    (mix 1.11.2) lib/mix/task.ex:394: Mix.Task.run_task/3

The error does not always occur at the same location. In the above example, I got it while it was trying to remove argon2_elixir but it can really be any folder.

I’m on Windows 10.

The only trend I’ve noticed is that I upgraded from Elixir 1.9.2 to 1.11.2 and this error has been happening much more frequently now — I’d say about 80-90% of the time. Previously, it was pretty rare.

Have you tried sudo chown -R myuser:myuser elixir_project_dir/? I had this problem once and that’s how I solved it. Actually I might have changed the containing directory’s ownership, I don’t remember well.

I don’t think sudo or chown are Windows commands. I do the Windows equivalent when running the terminal and Visual Studio, which is “Run as administrator”.

Oh, I wrongly assumed you were using WSL.

In that case, have you tried Windows’ recursive ACL replacements? Through Windows Explorer’s UI?

Does the behavior continue when you disable antivirus scanning? I remember chasing down a mysterious “directory not writeable” error back in Rails 2 that was ultimately caused by antivirus locking a newly-created directory for 100 ms at an inconvenient time during gem unpacking.

1 Like