简体   繁体   中英

Mix can't access a directory it just created to run the Phoenix server?

I am trying to run the Phoenix demo application per the official guide from an Administrator PowerShell session where I am the admin on my machine. I have installed every dependency but when I try to run mix phx.server , it tells me that it couldn't remove a file because (it's) not the owner. It seems odd that the using mix phx.new hello wouldn't have full control over this file that it just created. See the following output from my PowerShell session:

PS C:\users\Isaiah Nelson\Lab> cd hello
PS C:\users\Isaiah Nelson\Lab\hello> mix ecto.create
Compiling 13 files (.ex)
Generated hello app
The database for Hello.Repo has been created
PS C:\users\Isaiah Nelson\Lab\hello> mix phx.server
** (File.Error) could not remove file "c:/users/Isaiah Nelson/Lab/hello/_build/dev/lib/hello/priv": not owner
    (elixir) lib/file.ex:1128: File.rm!/1
    (mix) lib/mix/utils.ex:452: Mix.Utils.symlink_or_copy/2
    (mix) lib/mix/project.ex:644: Mix.Project.build_structure/2
    (mix) lib/mix/tasks/compile.all.ex:21: Mix.Tasks.Compile.All.run/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/compile.ex:96: Mix.Tasks.Compile.run/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/app.start.ex:58: Mix.Tasks.App.Start.run/1

I have since tried scouring the documentation on the Mix Task for phx.server but found no clues why this has happening. I have also even tried to set the 'hello' directory owner to Administrators, my user (Isaiah Nelson) and 'Everyone' with full control and inherited permissions but still I cannot run the demo app without getting this error. Is this a issue with Mix creating files in Windows via Powershell or is this some other Windows file permission issue? Either way, how I might fix it so I can run the demo?

If there is no reason to run phx app as administrator, you could "take" ownership recursively of the folder where project is located. Right click on folder then Properties > Securty > Advanced (button) then in new window Observe Owner at the top, click on "Change" link and find&pick your username. Click ok to close search dialog, then select "Replace all child object permission entries with inheritable permission entries from this object". Finally click Ok (or Apply) and try to run app without elevated rights.

EDIT

I found that in some cases editing code from WSL and later without WSL can mix access rights on file system leading to this or similar behavior, eg can't move folder to different location. If this is your case, then I suggest you to decide where your dev environment is, in WSL or in Win.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM