Skip to content

Commit

Permalink
Only print the first line of errors in values
Browse files Browse the repository at this point in the history
Before:
```
nix-repl> legacyPackages.aarch64-darwin.pythonPackages.APScheduler
«error: Package ‘python-2.7.18.7’ in /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/pkgs/development/interpreters/python/cpython/2.7/default.nix:335 is marked as insecure, refusing to evaluate.

Known issues:
 - Python 2.7 has reached its end of life after 2020-01-01. See https://www.python.org/doc/sunset-python-2/.

You can install it anyway by allowing this package, using the
following methods:

a) To temporarily allow all insecure packages, you can use an environment
   variable for a single invocation of the nix tools:

     $ export NIXPKGS_ALLOW_INSECURE=1

   Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
         then pass `--impure` in order to allow use of environment variables.

b) for `nixos-rebuild` you can add ‘python-2.7.18.7’ to
   `nixpkgs.config.permittedInsecurePackages` in the configuration.nix,
   like so:

     {
       nixpkgs.config.permittedInsecurePackages = [
         "python-2.7.18.7"
       ];
     }

c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
   ‘python-2.7.18.7’ to `permittedInsecurePackages` in
   ~/.config/nixpkgs/config.nix, like so:

     {
       permittedInsecurePackages = [
         "python-2.7.18.7"
       ];
     }

»
```

After:
```
nix-repl> legacyPackages.aarch64-darwin.pythonPackages.APScheduler
«error: Package ‘python-2.7.18.7’ in /nix/store/6s0m1qc31zw3l3kq0q4wd5cp3lqpkq0q-source/pkgs/development/interpreters/python/cpython/2.7/default.nix:335 is marked as insecure, refusing to evaluate.»
```
  • Loading branch information
9999years committed Mar 10, 2024
1 parent ac73062 commit 5ef4cb3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libexpr/print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,12 @@ class Printer
{
if (options.ansiColors)
output << ANSI_RED;
output << "«error: " << filterANSIEscapes(e.info().msg.str(), true) << "»";
auto message = filterANSIEscapes(e.info().msg.str(), true);
auto newline = message.find('\n');
if (newline != std::string::npos) {
message = message.substr(0, newline);
}
output << "«error: " << message << "»";
if (options.ansiColors)
output << ANSI_NORMAL;
}
Expand Down

0 comments on commit 5ef4cb3

Please sign in to comment.