jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.69k stars 141 forks source link

Exception on non-existent directory for :plt_core_path #398

Open jrmnl opened 4 years ago

jrmnl commented 4 years ago

Environment

elixir: 1.10.3 otp_release: 23.0

Current behavior

When you set :plt_core_path to non existent folder you will get following exceiption on mix dialyzer:

...
Creating dialyxir_erlang-23.0.plt
:dialyzer.run error:     The PLT file ./my_non_existent_folder/dialyxir_erlang-23.0.plt is not writable
Looking up modules in dialyxir_erlang-23.0.plt
** (Mix) Could not open ./my_non_existent_folder/dialyxir_erlang-23.0.plt: no such file or directory

Expected behavior

You can successfully create plt files in non existent folder.

jeremyjh commented 4 years ago

You can successfully create plt files in non existent folder.

Is this what people would really expect? Is there another mix task that handles non-existent paths that way for example? I'm just not really sure that the expectation should be to silently create the full path.

asummers commented 4 years ago

I would support a --create-if-not-exists type flag but creating by default is surprising behavior to me as a user.

jrmnl commented 4 years ago

You can successfully create plt files in non existent folder.

Is this what people would really expect? Is there another mix task that handles non-existent paths that way for example? I'm just not really sure that the expectation should be to silently create the full path.

If I specify :plt_file in non-existent path it will create it, for example. And here :plt_core_path sounds like output folder if it's empty or not exists.

--create-if-not-exists makes usage less obvious.

When this error was occured my first thoughts were:

  1. Is provided path correct?
  2. Do I have rights to create folders here?
jeremyjh commented 3 years ago

@asummers after looking at this more closely I've kind of come around to @jrmnl point of view here - since this is a file we create, it may not be surprising to create its path and we already do this when we copy the base PLT's to the target directory.