Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run builds in a pseudo-terminal #2878

Merged
merged 4 commits into from
Jun 17, 2019
Merged

Run builds in a pseudo-terminal #2878

merged 4 commits into from
Jun 17, 2019

Conversation

edolstra
Copy link
Member

This allows many programs (e.g. gcc, clang, cmake) to print colorized log output (assuming $TERM is set to a value like xterm).

There are other ways to get colors, in particular setting CLICOLOR_FORCE, but they're less widely supported and can break programs that parse tool output.

Example output:

nix-colors

@edolstra edolstra added improvement UX The way in which users interact with Nix. Higher level than UI. labels May 17, 2019
@dtzWill
Copy link
Member

dtzWill commented May 18, 2019

👍

After the --print-build-logs option I was really hoping for something like this, being somewhat disappointed my logs weren't already flush with color goodness. 😁

There are a few packages (if I dig up a good example I'll report back) that don't neatly handle not having a pty either at all or as stdin. This has caused strange behavior between sandbox/non-sandboxed builds in the past. Anyway this is all my way of saying "this is great and might improve some other pain points a bit too" 😁.


Setting TERM=xterm-256color raises questions/concerns about providing appropriate terminfo and such to builders, and is a hack since we're not xterm at all-- a common kludge but a kludge nevertheless :). TERM=nixbuild! 😁. We don't plan an actually parsing/responding to codes, which might be unexpected or problematic since a well-behaved program being told we're an xterm might expect responses. Shrug, solving this cleanly may take more work and cooperation elsewhere to be worth it. Shame, though :).

EDIT: shorter but also bits about TERM and such :)

@edolstra
Copy link
Member Author

Yeah, it will be interesting to see how many packages fail to build because of this. The stdenv bootstrap worked fine BTW.

Regarding terminfo, anything in Nixpkgs that uses ncurses should work because it contains terminfo. There might be a better choice than xterm-256color though...

@edolstra edolstra changed the base branch from master to flakes May 22, 2019 12:55
This allows many programs (e.g. gcc, clang, cmake) to print colorized
log output (assuming $TERM is set to a value like "xterm").

There are other ways to get colors, in particular setting
CLICOLOR_FORCE, but they're less widely supported and can break
programs that parse tool output.
@edolstra edolstra changed the base branch from flakes to master June 16, 2019 18:08
@edolstra edolstra merged commit 4b214e6 into master Jun 17, 2019
@edolstra edolstra deleted the run-in-pts branch June 21, 2019 15:36
@nh2
Copy link
Contributor

nh2 commented Dec 27, 2019

FYI this change made some Python

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 84: ordinal not in range(128)

errors go away in a way that I don't quite understand, see:

NixOS/nixpkgs#75676 (comment)

@nh2
Copy link
Contributor

nh2 commented Jan 28, 2020

errors go away in a way that I don't quite understand

I understand it now, Python 2 detects the TTY to determine the default stdout encoding. Written up on NixOS/nixpkgs#75676 (comment).

infinisil added a commit to infinisil/nixpkgs that referenced this pull request Feb 17, 2020
It seems that there might be hydra machines that run an older version of Nix
where NixOS/nix#2878 is not yet included
(unconfirmed)

In addition crystal 0.32.1 has a bug that only occurs when there is no
tty: crystal-lang/crystal#8609

Combining this lead to a crystal build failing: https://hydra.nixos.org/build/113074265

This fixes that probably rather uncommon occurence by applying the
upstream fix for the bug: crystal-lang/crystal#8609
infinisil added a commit to infinisil/nixpkgs that referenced this pull request Feb 18, 2020
It seems that there might be hydra machines that run an older version of Nix
where NixOS/nix#2878 is not yet included
(unconfirmed)

In addition crystal 0.32.1 has a bug that only occurs when there is no
tty: crystal-lang/crystal#8609

Combining this lead to a crystal build failing: https://hydra.nixos.org/build/113074265

This fixes that probably rather uncommon occurence by applying the
upstream fix for the bug: crystal-lang/crystal#8609
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX The way in which users interact with Nix. Higher level than UI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants