Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mix.Shell.cmd error when upgraded to elixir 1.6.1

My code was working fine on elixir 1.5.2 and then I upgraded to elixir 1.6.1. It gave me Mix.Shell.cmd/2 is undefined or private error. This is the code

   def run(args) do
     file = List.first(args) || "priv/static/apiv1docs.json"
     Mix.Shell.cmd("rm -rf " <> file, &IO.puts(&1))
     IO.puts("Removed " <> file)
   end

It gave me error.Mix.Shell.cmd/2 is undefined or private error. Did you mean one of cmd/3.

It was working fine before on 1.5.2.

Any help would be much appreciated

Thanks

like image 295
script Avatar asked Dec 31 '25 08:12

script


1 Answers

Mix.Shell.cmd takes 3 arguments:

cmd(command, options, callback)

You can pass an empty list as a second argument to use default options.

You can see the docs here

In 1.5.2 the function definition had [] as a default value for options:

cmd(command, options \\ [], callback)

. I'm not sure why they changed it

Mix.Shell.cmd/3 v1.5.2

like image 92
Ooba Elda Avatar answered Jan 05 '26 10:01

Ooba Elda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!