mnishiguchi

mnishiguchi

Nerves Core Team

Can we prevent mix archive.install from installing improper archive?

It seems like currently any Elixir package can be locally installed using
mix archive.install hex <package-name> command; however locally installing a
wrong package can negatively affect our local development environment particularly when dependencies are involved.

As an example, for Nerves project, we need to locally install one package called
nerves_bootstrap by running mix archive.install hex nerves_bootstrap.

But when we accidentally install nerves instead of nerves_bootstrap,
mix deps.get suddenly stops working in all the local Nerves firmware projects.

$ mix archive
* hex-2.0.4
* nerves-1.9.3   #<-- this is bad because it should not exist locally
* nerves_bootstrap-1.11.3
* phx_new-1.6.15
Archives installed at: /Users/mnishiguchi/.asdf/installs/elixir/1.14.3-otp-25/.mix/archives

We get an error that is not directly related to the mistake we make. The error
may looks like this:

mix deps.get
...
All dependencies are up to date

Nerves environment
  MIX_TARGET:   grisp2
  MIX_ENV:      dev

Checking for prebuilt Nerves artifacts...
  Checking nerves_system_grisp2...
  => Trying https://github.com/nerves-project/nerves_system_grisp2/releases/download/v0.6.0/nerves_system_grisp2
-portable-0.6.0-3B7C7BE.tar.gz

22:32:18.982 [notice] Application eex exited: :stopped
** (MatchError) no match of right hand side value: {:error, {:castore, {'no such file or directory', 'castore.ap
p'}}}
    (nerves 1.9.3) lib/nerves/utils/http_client.ex:24: Nerves.Utils.HTTPClient.start_link/0
    (nerves 1.9.3) lib/nerves/artifact/resolvers/uri.ex:14: Nerves.Artifact.Resolvers.URI.get/1
    (nerves 1.9.3) lib/nerves/artifact/resolver.ex:20: Nerves.Artifact.Resolver.do_get/3
    (nerves 1.9.3) lib/mix/tasks/nerves.artifact.get.ex:65: Mix.Tasks.Nerves.Artifact.Get.get_artifact/2
    (elixir 1.14.3) lib/enum.ex:975: Enum."-each/2-lists^foreach/1-0-"/2
    (mix 1.14.3) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4
    (nerves_bootstrap 1.11.3) lib/mix/tasks/nerves.deps.get.ex:15: Mix.Tasks.Nerves.Deps.Get.run/1
    (mix 1.14.3) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4``

Now I know the error occurs because the archive does not have dependencies but when
making this type mistake accidentally, the error message might not be so helpful in debugging.

Is there a way to prevent an improper archive from being accidentally installed locally, or
somehow show a little more informative error message?

Marked As Solved

fhunleth

fhunleth

Co-author of Nerves

Installing :nerves instead of :nerves_bootstrap will be prevented in the next release by this change. The way it works is by aliasing archive.build to raise with an error message.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

electic
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
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
ashish173
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

We're in Beta

About us Mission Statement