4

When sudo apt-get install -y blender redirects to /dev/null , the installing process completed without any warnings or errors.

But when sudo apt install -y blender redirects to /dev/null , this warning is shown :

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

So what's difference between apt-get and apt commands that cause this warning ?

I know that it's better to use apt instead of apt-get, but how to redirect the apt output without this warning ?

Is there another way to make apt less noisy ? (beacause -q and -qq options are not silently as they be should)

  • 3
    If you feel the apt warning should be mute-able, then please file a bug report, preferably with a patch. Personally, I think it's quite decent of the apt developers to warn us that it's an unstable interface. – user535733 Mar 27 '17 at 13:45
  • 1
    Why do you say it's better to use apt then apt-get? – Nacht Mar 27 '17 at 22:50
  • It sounds to me like the apt developers want you to use it interactively, but go use apt-get in your scripts. – Jonathan Cast Apr 02 '17 at 03:25

2 Answers2

7

If you are redirecting the output in order not to see it at all, then you can ignore the warning. It's intended to tell you that if you want to read the output later as a log, you can expect clearer information if you use apt-get, since some of the dynamic output from apt is not captured accurately.

Apparently APT is smart enough to realise you are redirecting its output but not to understand where you are sending it.

If you need to you can always read the logged output, by the way; it's automatically saved in /var/log/apt/term.log (and compressed and rotated when it gets old).

Zanna
  • 70,465
  • 1
    In relation to your second paragraph: "apt is [not smart enough] to understand where you are sending it", no program can tell where it has been redirected because redirection (at least in sh and bash) is handled by the shell interpreter – cat Mar 27 '17 at 14:52
  • 2
    @cat A program can't tell what's at the other end of a pipe (i.e. whether it's just less or some convoluted awk script), but it can tell whether it's been sent to a file, or a pipe, or a device (and /dev/null specifically could be identified by checking the major and minor numbers), with fstat. – Random832 Mar 27 '17 at 16:37
5

The warning is printed to the standard error output. You can redirect it using 2>.

The command

sudo apt install -y blender > /dev/null 2> /dev/null

will run completely silently. (It also means that any other errors and warnings will be discarded.)

Melebius
  • 11,431
  • 9
  • 52
  • 78