nerves icon indicating copy to clipboard operation
nerves copied to clipboard

nerves.artifact task fails when there's an existing artifact

Open SteffenDE opened this issue 3 years ago • 0 comments

Current behavior

$ git clone https://github.com/nerves-project/nerves_system_rpi4.git
$ cd nerves_system_rpi4
$ git checkout v1.16.1
$ mix deps.get
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  earmark_parser 1.4.13
  elixir_make 0.6.2
  ex_doc 0.24.2
  makeup 1.0.5
  makeup_elixir 0.15.1
  makeup_erlang 0.1.1
  nerves 1.7.8
  nerves_system_br 1.16.1
  nerves_system_linter 0.4.0
  nerves_toolchain_aarch64_nerves_linux_gnu 1.4.3
  nerves_toolchain_ctng 1.8.4
  nimble_parsec 1.1.0
* Updating nerves (Hex package)
* Updating nerves_system_br (Hex package)

Nerves environment
  MIX_TARGET:   target
  MIX_ENV:      dev

==> nerves
cc -c -O2 -Wall -Wextra -Wno-unused-parameter -std=c99 -D_GNU_SOURCE -o /root/nerves_system_rpi4/_build/target_dev/lib/nerves/obj/port.o src/port.c
cc /root/nerves_system_rpi4/_build/target_dev/lib/nerves/obj/port.o  -o /root/nerves_system_rpi4/_build/target_dev/lib/nerves/priv/port
Compiling 41 files (.ex)
Generated nerves app
==> nerves_system_rpi4
Resolving Nerves artifacts...
  Resolving nerves_system_rpi4
  => Trying https://github.com/nerves-project/nerves_system_rpi4/releases/download/v1.16.1/nerves_system_rpi4-portable-1.16.1-710BFB0.tar.gz

18:29:55.622 [warn]  Description: 'Authenticity is not established by certificate path validation'
     Reason: 'Option {verify, verify_peer} and cacertfile/cacerts is missing'


18:29:55.813 [warn]  Description: 'Authenticity is not established by certificate path validation'
     Reason: 'Option {verify, verify_peer} and cacertfile/cacerts is missing'

|==================================================| 100% (985 / 985) MB
  => Success
  Cached nerves_toolchain_aarch64_nerves_linux_gnu
$ mix nerves.artifact
==> nerves
==> nerves_system_br
Generated nerves_system_br app
==> nerves_toolchain_ctng
Compiling 1 file (.ex)
Generated nerves_toolchain_ctng app
==> nerves_toolchain_aarch64_nerves_linux_gnu
Generated nerves_toolchain_aarch64_nerves_linux_gnu app
==> nerves_system_linter
Compiling 14 files (.ex)
Generated nerves_system_linter app
==> nerves_system_rpi4
Generated nerves_system_rpi4 app

Nerves environment
  MIX_TARGET:   target
  MIX_ENV:      dev

Creating Artifact Archive
spawn: Could not cd to /root/nerves_system_rpi4/.nerves/artifacts/nerves_system_rpi4-portable-1.16.1
** (MatchError) no match of right hand side value: {:error, ""}
    (nerves 1.7.8) lib/nerves/artifact.ex:53: Nerves.Artifact.archive/3
    (nerves 1.7.8) lib/mix/tasks/nerves.artifact.ex:67: Mix.Tasks.Nerves.Artifact.run/1
    (mix 1.12.2) lib/mix/task.ex:394: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.12.2) lib/mix/cli.ex:84: Mix.CLI.run_task/2

I've come across this issue as I've setup a CI Pipeline for a custom nerves system and it failed once trying to run the pipeline from the same commit again.

Expected behavior

Either the command could just print a message that the artifact already exists and exit successfully, or the artifact task could remove the offending directory before trying to run the build. Another option would be to skip the current project when resolving artifacts. What do you think?

SteffenDE avatar Jul 24 '21 16:07 SteffenDE