yq 失败,显示”权限被拒绝”。

huangapple go评论74阅读模式
英文:

yq fails with "permission denied"

问题

为什么在VSCode终端中会出现这个错误?

cat foo.json | yq -P > foo.yaml


> 错误:写入/dev/stdout:权限被拒绝

但这个命令可以正常工作:

cat foo.json | yq -P | cat > foo.yaml


我可以使用`touch`创建文件"foo.yaml",并使用`rm`删除它。

我认为这与文件/目录权限无关。

我认为这可能与工具`yq`的特殊性有关。

没有使用`sudo`。

操作系统:Ubuntu 22.04

这仅在VSCode的终端中发生,而在gnome-terminal中可以正常工作。

`yq`是通过snap安装的。

这可能与这个问题相关:https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1849753
英文:

Why does this fail in the terminal of vscode?

cat foo.json | yq -P  > foo.yaml

> Error: write /dev/stdout: permission denied

But this does work:

cat foo.json | yq -P | cat > foo.yaml

I can create the file "foo.yaml" with touch and remove it with rm.

I don't think it is related to file/directory permissions.

I think it must be something special about the tool yq.

No sudo is involved.

OS: Ubuntu 22.04

This only happens in the console of vscode, it works in a gnome-terminal.

yq is installed via snap.

It could be related to this issue: https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1849753

答案1

得分: 3

不是根本原因的解决方案,但至少是一个解释和解决方法:

这与vscode有关,而不是与yq有关。

其他命令也发生了类似的情况。例如:kubectl:

kubectl run --image=nginx nginx --dry-run=client -o yaml  > p.yaml

错误:写入/dev/stdout:权限被拒绝

我从未理解为什么要创建snap。似乎与这个问题有关:https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1849753

我通过brew for linux安装了kubectl(和yq),现在我不再遇到“权限被拒绝”的错误。

英文:

Not a solution of the root cause, but at least an explanation and a work around:

This is related to vscode, not to yq.

The same happens with other commands. For example: kubectl:

kubectl run --image=nginx nginx --dry-run=client -o yaml  > p.yaml

error: write /dev/stdout: permission denied

I never understood why snap was created. It seems to be related to this issue: https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1849753

I installed kubectl (and yq) via brew for linux and now I don't get the "permission denied" error.

huangapple
  • 本文由 发表于 2023年3月7日 16:47:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75659711.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定