Sinc
Dialyzer seems not to expect System.cmd to return a non-zero code
I ran dialyzer on this new code (with both Elixir 1.7 and 1.12) and am getting the error:
The pattern
variable_error
can never match, because previous clauses completely cover the type
:ok.
It points at the line in maybe_gen_certificates that does the put_error. I don’t understand why. The spec for generate_certificates should be correct, specifying :ok | {atom(), atom()}, and the with statement should be able to fail with {_, non_zero_integer} and return that as response. What am I missing?
defp maybe_gen_certificates(config, false) do
case generate_certificates() do
:ok -> config
error -> put_error(config, :certificate, error)
end
end
@spec generate_certificates() :: :ok | {atom(), atom()}
def generate_certificates do
{key, cert} = keys()
write_keys_permissions({key, cert})
response =
with {_, 0} <- System.cmd("openssl", ~w(genrsa -out #{key} 2048)),
{_, 0} <- System.cmd("openssl", ~w(rsa -in #{key} -out #{cert} -outform PEM -pubout)),
do: :ok
reset_keys_permissions({key, cert})
response
end
Thanks! 
Marked As Solved
LostKobrakai
System.cmd and therefore generate_certificates returns {Collectable.t(), exit_status :: non_neg_integer()} not {atom(), atom()} in the case of a non zero exit status.
Popular in Questions
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size?
Thanks
New
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217
Let’s say I have a map with required and optional k...
New
Other popular topics
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Hey :wave:t3: Elixir community,
I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New








