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

Recursion halted on mix alias using "File.cp_r" #14249

Closed
RaymondLoranger opened this issue Feb 4, 2025 · 1 comment
Closed

Recursion halted on mix alias using "File.cp_r" #14249

RaymondLoranger opened this issue Feb 4, 2025 · 1 comment

Comments

@RaymondLoranger
Copy link

Elixir and Erlang/OTP versions

I have a mix.exs that invokes the following docs alias:

  defp aliases do
    [
      docs: ["docs", &copy_images/1]
    ]
  end

  defp copy_images(_) do
    File.cp_r("images", "doc/images",
      on_conflict: fn src, dst ->
        IO.gets(~s|Overwriting "#{dst}" with "#{src}".\nProceed? [Yn]\s|) in [
          "y\n",
          "Y\n"
        ]
      end
    )
  end

When I run mix docs the 8 files in images are copied recursively to doc/images as illustrated in the attached.
However when I run mix cmd elixir --color -S mix docs only the first file is copied and the process freezes.

mix docs.docx

mix.exs.docx

Operating system

Windows 10

Current behavior

When I run mix cmd elixir --color -S mix docs only the first file is copied and the process is frozen.

Expected behavior

When I run mix cmd elixir --color -S mix docs all 8 files should be copied recursively without any freezing.

@josevalim
Copy link
Member

Yes, in this case it is intentional. mix cmd does not forward stdin requests to the invoked subcommand, so you cannot interact with the underlying terminal. In this case, I would recommend not relying on mix cmd to invoke Elixir itself. If you really need to shell out with stdin redirection, I recommend using projects like porcelain or erlexec.

@josevalim josevalim closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants