Strange mix compile errors

I have been getting this error a lot this evening …

C:\Elixir\bothost
λ mix compile
===> Compiling elli
** (File.Error) could not remove file "c:/Elixir/bothost/_build/dev/lib/elli/ebin": not owner
    (elixir) lib/file.ex:788: File.rm!/1
    (mix) lib/mix/utils.ex:318: Mix.Utils.symlink_or_copy/2
    (mix) lib/mix/project.ex:509: Mix.Project.build_structure/2
    (elixir) lib/file.ex:1162: File.cd!/2
    (mix) lib/mix/tasks/deps.compile.ex:243: anonymous fn/3 in Mix.Tasks.Deps.Compile.build_structure/2
    (elixir) lib/enum.ex:645: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:645: Enum.each/2
    (mix) lib/mix/tasks/deps.compile.ex:87: anonymous fn/4 in Mix.Tasks.Deps.Compile.compile/2

If i manually delete the _build folder, i’m then able to compile

This just started today. What could be wrong?

I’m running Elixir 1.4.1 on windows 10

I have added the Eveyone account and given it Full Permissions to that folder, still no luck

1 Like

You need to run mix as admin. Windows 10 has this stupidity that symlinks can only be made by a program running as administrator or by guest, no user account has the capability no matter the permissions you give that account, and guests can because they are limited in there access anyway. Yes it is stupid, but it is Windows.

Just run the iex or mix programs ‘as administrator’ and all is fine, symlinks work, no more race conditions with file copies, etc… etc…

1 Like

I’m already running as administrator.

No luck.

This just started today.

I have moved from 1.4.1 to 1.4.2 in an attempt to fix this, restarted windows… no joy :frowning:

I even added everyone as an account to my root elixir projects folder and gave it ownership…

1 Like

First, make certain elixir is being run ‘as administrator’, not just that your account is administractor (that is not enough because programs are not run as administrator unless you explicitly do so).

Second, if the _build directory is already corrupt you have to clear it before running the iex/mix ‘as administrator’ or it will not help, once corrupt it stays corrupt, because windows NTFS stupidity.

Third, adding people to permission of other accounts or whatever will do nothing, the program itself has to be run ‘as administrator’, not the account it is running in.

EDIT:
Remember, it is like linux in this regard, just because your account on linux has sudo access, does not mean a program is run as root unless you ‘sudo’ it, just because you have an administrator account on windows does not mean the program is running as administrator, you have to tell windows to run it as administrator using the usual ways (I use a set of scripts I made, iex_admin and mix_admin, can make your own too for ease of use).

1 Like

This might be an issue. I run elixir, iex, mix from a comand line.

I can see the .bat files in the C:\Program Files (x86)\Elixir\bin folder

How can i set them to run as admin no such option on the property page of a .bat file

1 Like

You can make a shortcut and set it to always launch as administrator, however you will get the stupid Windows UAC box every-single-irritating-time. My scripts, in comparison, elevate the command prompt to administrator if it is not, so I only get it once per session. Or whenever you open the command prompt right click on the command prompt and ‘run as administrator’ anyway. Or if using conemu then right-click the tab and ‘restart as administrator’. Or whatever other way, there are dozens that are easily done. Or you can prefix the command with the right incantation to launch the mix/iex subcommand as administrator (windows version of ‘sudo’, but far far more wordy). It is all standard normal irritating Windows stuff. :slight_smile:

Dev’ing on Windows is a pain, no matter the language. I know it all too well as Windows is what I use at work and Linux at home, Linux is so significantly better for programming.

1 Like

I think this might help… sigh been figting this windows dragon for the past few hours

will try again in the morning

1 Like

That is indeed very similar to what my script does, but I use powershell instead. It is a bit messy of a way and may cause more UAC popups than you’d prefer, but it works. :slight_smile:

And yes, the Windows Dragon is big and painful. :wink:

For now, I’d say just launch your command prompt ‘as administrator’, that at least gets you going for now, just be sure to clear the _build directory once more. :slight_smile:

2 Likes

But lets look at this carfuly really.

I’ve never had this problem before today.

Why all of a sudden?

1 Like

I’ve had similar experiences with multiple projects, they work fine for a long time, then suddenly those errors, which I eventually tracked down to a race condition in how Windows NTFS saves files out, it is not what one would call ‘atomic’, not like a sync is on linux anyway. Clearing and resetting does not fix it. I’m unsure as to the trigger, it might be fragmentation, alignment of the files, how full the drive is, or a variety of other things, but once it starts happening it keeps happening, not just in elixir but in other languages I’ve experienced as well…

I’m just glad that elixir has some kind of work-around, since it tries to symlink if it is capable instead of copy (saves a lot on speed too) that works around the issue, which you can enable by running as administrator. Other languages I’ve dealt with do not have such a resolution and I often get stuck for a long period…

1 Like

Still no luck… 3:00 am here … i’m stuck on this :frowning:

None of the stackoverlow scripts helps.

We really need to find a root casue and fix this once and for all.

I’m at a loss for what NTFS is doing that could be causing this crap.

1 Like

Lets start really at the beginning and do it manually!

  1. Open startmenu
  2. Type “cmd.exe”
  3. right click the entry of the terminal, select “Run as Administrator”
  4. cd into your project dir
  5. rm -rf deps/ _build/ (or whatever the windows equivalent is, even under windows I only use bash)
  6. mix do deps.get, deps.compile, compile
  7. be happy, and always use an elevated terminal from now on…
2 Likes

@NobbZ

Thanks for the steps, but I have done all this and still have the same issue.

In fact, i just ran through your list again step by step and still no luck.

Like I had mentioned, this started suddenly on a machine that had been working smoothly with Elixir.

I have no idea what could have triggered this.

The work around is to keep deleting the _build folder each time i need to re-build.

1 Like

Maybe you broke already even more when you altered user rights/restrictions on that folder?

Does the problem persist even after completely wiping everything and freshly checking out from VCS?

1 Like

Yes the problem persits.

I had not mentioned, i’m using some local folder references in my mix.config deps. But I still dont think this is the issue…

  defp deps do
    [
      {:httpoison, "~> 0.11"},
      {:poison, "~> 3.1"},
      {:elli, path: "c:/elixir/elli"},
      {:tds, path: "c:/elixir/tds"}
    ]
  end
1 Like

@NobbZ @OvermindDL1

Seem i had a defective local copy of one of the dependencies i was referencing from a local folder, switching back to the git hosted copy seems to have fixed the issues.

I will clone a fresh copy of said dependency and apply my local changes to it again.

Thanks for the suggestions guys.

1 Like

Heh, yeah if you have local dependencies they need to be wiped too when that is done. ^.^

2 Likes