Skip to content

Conversation

@edennis
Copy link
Contributor

@edennis edennis commented Mar 23, 2023

This came up today with a custom formatter that we have for json files. Vscode's ElixirLS created a directory called "apps/our_app/.elixir_ls/build/test/lib/phoenix/priv/templates/phx.gen.json" and running mix format resulted in the following error:

** (File.Error) could not read file "/Users/edennis/sandbox/...": illegal operation on a directory
    (elixir 1.13.4) lib/file.ex:355: File.read!/1
    (mix 1.13.4) lib/mix/tasks/format.ex:563: Mix.Tasks.Format.format_file/2
    (elixir 1.13.4) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
    (elixir 1.13.4) lib/task/supervised.ex:34: Task.Supervised.reply/4
    (stdlib 3.17.2.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

The fact that we're accidentally formatting files from ElixirLS is of course an issue of ours, but with the exception of :stdin, I'd say we'd only want to ever try to format regular files.

@edennis edennis force-pushed the mix-format-only-format-regular-files branch from f467168 to 0917730 Compare March 23, 2023 10:36
Copy link
Member

@whatyouhide whatyouhide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, I think it makes sense. 💯

@josevalim josevalim merged commit 57f0648 into elixir-lang:main Mar 23, 2023
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

josevalim pushed a commit that referenced this pull request Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants