Pkg.jl icon indicating copy to clipboard operation
Pkg.jl copied to clipboard

Artifact selection hooks should not read the output TOML dictionary from `stdout`

Open DilumAluthge opened this issue 2 years ago • 3 comments

Currently, artifact selection hooks expect that the hook will print the resultant TOML dictionary to stdout.

Unfortunately, this means that if you have any other output being printed to stdout, the artifact selection hooks break. Some examples of this include:

  1. You have a custom sysimage, and in that custom sysimage there are some __init__() functions that print various output to stdout.
  2. You've enabled a debug mode in your packages, and this debug mode prints various debugging statements to stdout.

Instead of having artifact selection hook output printed to stdout, I would recommend an interface of the following:

  1. Before we run the artifact selection hook, we touch a temporary file, e.g. /tmp/mytempdir/myfile.toml, and we set ENV["JULIA_PKG_ARTIFACT_SELECTION_HOOK_OUTPUT"] = "/tmp/mytempdir/myfile.toml".
  2. When the hook runs, it writes its TOML dictionary out to the ENV["JULIA_PKG_ARTIFACT_SELECTION_HOOK_OUTPUT"] file.
  3. After the hook has run, Pkg reads the TOML dictionary in from the ENV["JULIA_PKG_ARTIFACT_SELECTION_HOOK_OUTPUT"] file.

The design mirrors the GITHUB_ENV file that GitHub Actions uses for passing output between steps.

DilumAluthge avatar Sep 06 '22 14:09 DilumAluthge

Sounds like a good idea to me

KristofferC avatar Sep 06 '22 14:09 KristofferC

Can this be done without breaking all existing releases? I don't think so?

Edit: I suppose packages must print to both for a while and in Pkg we use the file output if it is non-empty, otherwise stdout? Then over time the new system will take over.

fredrikekre avatar Sep 06 '22 14:09 fredrikekre

You've enabled a debug mode in your packages, and this debug mode prints various debugging statements to stdout.

Most of these stuff should probably print to stderr though.

KristofferC avatar Sep 07 '22 07:09 KristofferC