pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.21k stars 620 forks source link

Pants leaking install logs to stdout while installing a new version #20315

Closed grihabor closed 4 months ago

grihabor commented 7 months ago

Describe the bug When you run any goal, lets say pants list ::, and you don't have the declared pants_version installed yet, pants starts downloading the new version and writes the progress to stdout instead of stderr.

Pants version 2.18.1

OS Ubuntu 22.04

Additional info Here is a test test_script.sh:

#!/bin/bash

testScript() {
    assertEquals "$(pants list ::)" "//:file"
}

oneTimeSetUp() {
    echo '
[GLOBAL]
pants_version = "2.20.0dev1"

backend_packages = []
    ' >pants.toml
    echo 'data' >file.txt
    echo 'file(name="file", source="file.txt")' >BUILD
}

Here is pants.toml:

[GLOBAL]
pants_version = "2.18.1"

backend_packages = [
  "pants.backend.shell",
]

Here is BUILD:

shunit2_tests(name="tests")

Here is what you get when you run pants --no-local-cache test test_script.sh (make sure to switch pants version to a version you don't have installed):

$ pants --no-local-cache test test_script.sh 
23:06:57.25 [ERROR] Completed: Run tests with Shunit2 - //test_script.sh:tests - failed (exit code 1).
testScript
ASSERT:expected:<Found existing installation: setuptools 58.1.0
Uninstalling setuptools-58.1.0:
  Successfully uninstalled setuptools-58.1.0
//:file> but was:<//:file>

Ran 1 test.

FAILED (failures=2)

Bootstrapping Pants 2.19.0rc2
Installing pantsbuild.pants==2.19.0rc2 into a virtual environment at /home/grihabor/.cache/nce/3d6643e46b53e4cc0b2a0d5c768866226ddce3de1f57f80c4a02d8d39800fa8e/bindings/venvs/2.19.0rc2
New virtual environment successfully created at /home/grihabor/.cache/nce/3d6643e46b53e4cc0b2a0d5c768866226ddce3de1f57f80c4a02d8d39800fa8e/bindings/venvs/2.19.0rc2.
23:06:56.99 [INFO] Initializing scheduler...
23:06:57.13 [INFO] Scheduler initialized.
shunit2:ERROR testScript() returned non-zero return code.

✕ //test_script.sh:tests failed in 22.08s.

I've put everything in a repo to easily test https://github.com/grihabor/pants-writes-to-stdout-bug/tree/master (make sure to switch pants version to a version you don't have installed)

kaos commented 4 months ago

Fix in release: https://github.com/pantsbuild/scie-pants/releases/tag/v0.10.8

grihabor commented 4 months ago

Cool, thanks!