Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Phoenix.CodeReloader when mix.lock mtime changes without content change #6082

Closed
superhawk610 opened this issue Feb 11, 2025 · 1 comment

Comments

@superhawk610
Copy link

Environment

  • Elixir version (elixir -v):
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:11:11] [ds:11:11:10] [async-threads:1]

Elixir 1.18.1 (compiled with Erlang/OTP 27)
  • Phoenix version (mix deps):
* phoenix 1.7.19 (Hex package) (mix)
  locked at 1.7.19 (phoenix) ba4dc144
  ok
  • Operating system: MacOS Sequoia 15.3

Actual behavior

This error first appeared while working on a larger application, but I've isolated it to a minimal, reproducible example.

$ mix phx.new lockfile_issue
$ cd lockfile_issue
$ mix phx.server
# application loads correctly
$ touch mix.lock
$ mix phx.server
# the error shown below occurs

Whenever the mix.lock file's mtime changes, this error is encountered:

** (RuntimeError) could not compile application: lockfile_issue.

You must restart your server after changing the following files:

  * mix.lock


    (phoenix 1.7.19) lib/phoenix/code_reloader/server.ex:245: Phoenix.CodeReloader.Server.mix_compile_unless_stale_config/4
    (phoenix 1.7.19) lib/phoenix/code_reloader/server.ex:188: Phoenix.CodeReloader.Server.mix_compile/5
    (phoenix 1.7.19) lib/phoenix/code_reloader/server.ex:74: anonymous fn/4 in Phoenix.CodeReloader.Server.handle_call/3
    (phoenix 1.7.19) lib/phoenix/code_reloader/server.ex:308: Phoenix.CodeReloader.Server.proxy_io/1
    (phoenix 1.7.19) lib/phoenix/code_reloader/server.ex:72: Phoenix.CodeReloader.Server.handle_call/3
    (stdlib 6.0.1) gen_server.erl:2209: :gen_server.try_handle_call/4
    (stdlib 6.0.1) gen_server.erl:2238: :gen_server.handle_msg/6
    (stdlib 6.0.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

The error persists after stopping the phx.server process and restarting it. The error can be manually resolved with:

$ touch _build/dev/lib/**/.mix/compile.elixir

This error didn't occur before this commit.

I don't normally run touch mix.lock, but the lockfile mtime changes during some routine operations like running git checkout.

Expected behavior

The error isn't generated, or the error is resolved by restarting phx.server.

@SteffenDE
Copy link
Contributor

Fixed with d091d26, will be included in the next release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants