3

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

Ooba Elda
  • 1,622
  • 1
  • 12
  • 18
script
  • 1,667
  • 1
  • 12
  • 24

1 Answers1

3

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

Ooba Elda
  • 1,622
  • 1
  • 12
  • 18
  • 2
    I would report it as an issue; there were no depreciation warning, it should be backwards compatible. – Grych Feb 07 '18 at 18:59