Aurus7

Aurus7

Mix ecto.gen.migration "could not remove file" error

Hi Everyone,

I’ve been working through Programming Phoenix, and the sample project “Rumbl”. At one point, we’re asked to create a migration with the command mix ecto.gen.migration add_category_id_to_video. When I do this, I get the error ** (File.Error) could not remove file "...rumbl/_build/dev/lib/rumbl/priv": not owner. Stack trace:

   (mix) lib/mix/utils.ex:312: Mix.Utils.symlink_or_copy/2
   (mix) lib/mix/project.ex:414: Mix.Project.build_structure/2
   (mix) lib/mix/tasks/compile.all.ex:15: Mix.Tasks.Compile.All.run/1
   (mix) lib/mix/task.ex:296: Mix.Task.run_task/3
   (mix) lib/mix/tasks/compile.ex:85: Mix.Tasks.Compile.run/1
   (mix) lib/mix/task.ex:296: Mix.Task.run_task/3
   lib/mix/ecto.ex:61: Mix.Ecto.ensure_repo/2```
 I definitely am the owner of that folder, and I'm able to get around this and run the command successfully by manually deleting that folder beforehand.  Is there something I'm missing here that would have caused this?  I'm also getting this error now when running `mix ecto.migrate`, which I'd been able to do successfully in this project in the past.  I'm on Windows 10, by the way.  Thanks for your time.

Most Liked

OvermindDL1

OvermindDL1

You are not running with privileges that allow symlinking, so Phoenix has to copy the priv directory instead of link it. However with it being copied creates race conditions. Assuming you are running recent versions of Phoenix/Elixir you should have got a message in your terminal that stated that if you are not running without symlink privileges or something like that they you will experience significant performance degradation during development in addition to various errors. The error you get of ‘not owner’ is because the Windows file system has not finished synching files in the background so it is ‘owned’ by ‘SYSTEM’ at that second, but it reverts back to you when it is done (most of the time, if a copy happens while another is still synching in the background it can get perma-stuck). Yes NTFS sucks.

Either give your user access to permission to create symlinks, or run the server with admin permissions. It is a limitation of Windows, it cannot keep up with the code reloading and gets stuck like that when it happens rapidly, but by giving the server symlink (or admin) permissions (Why does windows not give it by default?!? Stupid…) then Phoenix can work-around the issue by just symlinking so there is only ever one copy. :slight_smile:

Source: I was the one that discovered this issue, it is native to Windows and how fast the BEAM compiles (too fast) and found the work-around, consequently I was the one that suggested that the message be added to the terminal (and it still reminds me to this day when I forget to elevate the server process). ^.^

EDIT: You may need to manually delete that directory ‘one-more-time’ to let the symlink happen, but that is a toss-up on whether it is required or not too.

KokoAleksander

KokoAleksander

Hi. Also new to Phoenix. Maybe there’s something related to Brunch (node) running as Administrator. I’m not much sure on this but maybe when building (also copies priv folder to _build folder), it can delete because is not the owner.

Not totally sure if this is the issue, but it may be a Node related issue.

Aurus7

Aurus7

Thanks for the detailed explanation. Running the shell as Administrator fixed it for the reasons you mentioned.

OvermindDL1

OvermindDL1

Nope, not brunch or node or even the BEAM, just how Windows works with lots of file changes very fast.

Awesome, glad to help. :slight_smile:

KokoAleksander

KokoAleksander

Love what NTFS still does. I recall some weird stuff when was developing PHP + Composer on Windows. When wanted to delete the vendor folder, in some cases there were many files nested in some cases with long names, and NTFS just failed on those cases.

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement