elixir-lang / elixir

Elixir is a dynamic, functional language for building scalable and maintainable applications
https://elixir-lang.org/
Apache License 2.0
24.51k stars 3.38k forks source link

`mix`: Error updating packages #5155

Closed OvermindDL1 closed 8 years ago

OvermindDL1 commented 8 years ago

Precheck

Doing a full update of packages of one of my apps, thus running mix deps.update --all.

Environment

Running mix deps.update --all produces:

$ mix deps.update --all
* Updating logger_file_backend (https://github.com/onkel-dirtus/logger_file_backend.git)
Running dependency resolution
Dependency resolution completed
  apex: 0.5.2
  base64url: 0.0.1
  bbmustache: 1.0.4
  bunt: 0.1.6
  cachex: 1.2.2
  canada: 1.0.1
  certifi: 0.4.0
  cf: 0.2.1
  combine: 0.9.2
  connection: 1.0.4
  cowboy: 1.0.4
  cowlib: 1.0.2
  credo: 0.4.9
  db_connection: 1.0.0-rc.5
  decimal: 1.1.2
  dialyxir: 0.3.5
  dogma: 0.1.7
  ecto: 2.0.4
  edeliver: 1.4.0
  erlware_commons: 0.21.0
  eternal: 1.0.3
  exrm: 1.0.8
  exrm_docker: 0.1.0
  fs: 0.9.2
  getopt: 0.8.2
  gettext: 0.11.0
  guardian: 0.12.0
  guardian_db: 0.7.0
  hackney: 1.6.1
  happy: 1.3.1
  httpoison: 0.8.3
  idna: 1.2.0
  inch_ex: 0.5.3
  jose: 1.8.0
  ldap_ex: 0.2.4
  metrics: 1.0.1
  mime: 1.0.1
  mimerl: 1.0.2
  mix_test_watch: 0.2.6
  nimble_csv: 0.1.0
  ok_jose: 2.0.0
  permission_ex: 0.4.0
  phoenix: 1.2.1
  phoenix_ecto: 3.0.1
  phoenix_html: 2.6.2
  phoenix_live_reload: 1.0.5
  phoenix_pubsub: 1.0.0
  plug: 1.2.0
  poison: 2.2.0
  poolboy: 1.5.1
  postgrex: 0.11.2
  providers: 1.6.0
  ranch: 1.2.1
  relx: 3.20.0
  ssl_verify_fun: 1.1.0
  timex: 2.2.1
  timex_ecto: 1.1.3
  tzdata: 0.5.9
  ueberauth: 0.3.0
  uuid: 1.1.4
* Updating phoenix (Hex package)
  Checking package (https://repo.hex.pm/tarballs/phoenix-1.2.1.tar)
  Fetched package
** (File.Error) could not remove files and directories recursively from "c:/Users/<myuser>/Projects/my_server/deps/phoenix": file already exists
    (elixir) lib/file.ex:919: File.rm_rf!/1
    (hex) lib/hex/scm.ex:111: Hex.SCM.checkout/1
    (mix) lib/mix/dep/fetcher.ex:61: Mix.Dep.Fetcher.do_fetch/3
    (mix) lib/mix/dep/converger.ex:174: Mix.Dep.Converger.all/9
    (mix) lib/mix/dep/converger.ex:114: Mix.Dep.Converger.all/7
    (mix) lib/mix/dep/converger.ex:99: Mix.Dep.Converger.all/4
    (mix) lib/mix/dep/converger.ex:50: Mix.Dep.Converger.converge/4
    (mix) lib/mix/dep/fetcher.ex:16: Mix.Dep.Fetcher.all/3

The server is not running, no open windows to that location or anywhere near. This happens every time the command is run.

Expected behavior

Deps would update.

Extra notes

Running rm -r deps/phoenix and then mix deps.update --all worked, thus showing the directory was not locked.

ericmj commented 8 years ago

This is a hex issue so please reopen at https://github.com/hexpm/hex. Unfortunately I don't know what the "file already exists" error means when removing a directory.

josevalim commented 8 years ago

On Windows it most likely means there is something using the current directory. Or a terminal session, a dangling file cursor, etc. maybe use file.rm_rf and print a warning if it cannot be removed due to this particular reason.

On Wednesday, August 24, 2016, Eric Meadows-Jönsson < notifications@github.com> wrote:

This is a hex issue so please reopen at https://github.com/hexpm/hex. Unfortunately I don't know what the "file already exists" error means when removing a directory.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/elixir-lang/elixir/issues/5155#issuecomment-242094859, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAlbjMCOxZALXSEE-UU5TX6Uwh57AnZks5qjFwpgaJpZM4JsE6O .

José Valim www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D

OvermindDL1 commented 8 years ago

This is a hex issue so please reopen at https://github.com/hexpm/hex. Unfortunately I don't know what the "file already exists" error means when removing a directory.

Ah thanks, I was searching for a hex github repo but somehow never found that, so I ended up here.

On Windows it most likely means there is something using the current directory. Or a terminal session, a dangling file cursor, etc. maybe use file.rm_rf and print a warning if it cannot be removed due to this particular reason.

I thought the same, but I could delete it manually with no problem... Would be nicer to print a reason, perhaps say it is unable to automatically remove it and to remove it manually then re-run? Would be nice to print that for each directory too instead of running, deleting, running, deleting next, etc... It happens on every one that has to update every time I update (also happens with the phoenix reloader sometimes as well, it cannot File.rm_rf the _build/dev/lib/my_server/priv/ with the error of:

** (File.Error) could not remove files and directories recursively from "c:/Users/<myuser>/Projects/my_server/_build/dev/lib/my_server/priv": file already exists
    (elixir) lib/file.ex:919: File.rm_rf!/1
    (mix) lib/mix/utils.ex:317: Mix.Utils.symlink_or_copy/2
    (mix) lib/mix/project.ex:414: Mix.Project.build_structure/2
    (phoenix) lib/phoenix/code_reloader/server.ex:111: Phoenix.CodeReloader.Server.mix_compile/1
    (phoenix) lib/phoenix/code_reloader/server.ex:83: Phoenix.CodeReloader.Server.mix_compile/3
    (phoenix) lib/phoenix/code_reloader/server.ex:40: anonymous fn/2 in Phoenix.CodeReloader.Server.handle_call/3
    (phoenix) lib/phoenix/code_reloader/server.ex:132: Phoenix.CodeReloader.Server.proxy_io/1
    (phoenix) lib/phoenix/code_reloader/server.ex:38: Phoenix.CodeReloader.Server.handle_call/3
    (stdlib) gen_server.erl:615: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:647: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

So I have my server start set to rm -r _build/dev/lib/my_server/priv/; iex --name devserver -S mix phoenix.server and I have to ctrl+c it every once in a while when that error pops up and hit up then enter again to clear and relaunch it.

I am starting to wonder if it is a bug in File.rm_rf! or something on windows since I can always manually delete it but it cannot...

ericmj commented 8 years ago

@OvermindDL1 I don't know what the underlying issue but I would suggest looking into if any handles are open to the directories or files inside the directory. This tool can help with that https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx. It could be that rm in the terminal does some harder force delete.

I would also appreciate any help with improving the error messages.

josevalim commented 8 years ago

I thought the same, but I could delete it manually with no problem...

Maybe it was the Elixir process itself holding a handle to the file or it was used to hold a handle to the file but the OS did not fully claim it back at the time. We had all kinds of hard to explain issues when we implemented archives on Windows.

josevalim commented 8 years ago

@OvermindDL1 closing this for now anyway. Please open up an issue on hex? :heart:

OvermindDL1 commented 8 years ago

Maybe it was the Elixir process itself holding a handle to the file or it was used to hold a handle to the file but the OS did not fully claim it back at the time. We had all kinds of hard to explain issues when we implemented archives on Windows.

That was my thought. I had indeed looked via Process Explorer many times to find what was holding c:/Users/<myuser>/Projects/my_server/_build/dev/lib/my_server/priv but it never found any results. I do not care too much about the hex one (though I will make a bug report there, thanks for the link again!) but the phoenix reloader one really really bugs, should I post that in the phoenix repo or is it more likely something in elixir or mix straight?

josevalim commented 8 years ago

The Phoenix one is likely a bug in Mix, maybe we could try something different but I have no clue about what.