mikefarah/yq

yq doesn't read stdin when called with sudo

ChristianS99 opened this issue ยท 7 comments

Describe the bug
yq doesn't seem to read stdin when called with sudo

Version of yq: 4.44.2
Operating system: ubuntu
Installed via: snap

Command

  1. echo "some: yaml" | yq .

  2. echo "some: yaml" | sudo yq .

Actual behavior

  1. outputs some: yaml
  2. doesn't output anything and doesn't return indefinitely (at least some minutes, didn't wait longer)

Expected behavior

  1. as it should be
  2. outputs some: yaml (as 1))

Additional context

Okay, but what the point or use case of using stdin + sudo ?

I'm curious

i don't use it like that, yq is used inside a script that is running with sudo, there is the same problem. I just reduced it to this.

So you mean the following script works without sudo, but doesn't with?

file.sh

#!/bin/sh

echo "some: yaml" | yq .
$ ./file.sh
$ sudo ./file.sh

actually i have yq . < <filename>, but in the reduced form , there wasn't a difference.

Thanks is clearer now.

Let's wait for maintainer feedback

Sorry for noise, it seems not to be a problem of reading stdin or yq at all:

  1. sudo yq . <filename>, hangs, too, there yq should open the file directly and read it
  2. on a system where yq (in same version) is installed directly, not with snap, sudo yq . <filename> and echo "some: yaml" | sudo yq . just work.

so its a WTF snap, I guess....

That's why I started using homebrew on Linux. Easy, not as complicated as nix