ITADN

-i doesn't work when stdin is not a tty

#17Closedantifuchs 创建于 2024-08-19
A
antifuchscommented
I was trying to run nix-auto-follow in a github action like so: ```yaml - run: nix run github:fzakaria/nix-auto-follow -- -i name: Re-follow flake inputs ``` But that results in a confusing error message: ``` Traceback (most recent call last): File "/nix/store/87m760nbmka40dy4fjbyxa3nbv73khah-nix-auto-follow/bin/.auto-follow-wrapped", line 9, in <module> sys.exit(start()) ^^^^^^^ File "/nix/store/87m760nbmka40dy4fjbyxa3nbv73khah-nix-auto-follow/lib/python3.11/site-packages/nix_auto_follow/cli.py", line 204, in start flake_lock_json: dict[str, Any] = json.loads(input_data) ^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/pfv4raslwhi3101k34[275](https://github.com/antifuchs/home/actions/runs/10454797537/job/28948273523#step:7:276)2v65zxkwrxq-python3-3.11.9/lib/python3.11/json/__init__.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/pfv4raslwhi3101k342752v65zxkwrxq-python3-3.11.9/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/nix/store/pfv4raslwhi3101k342752v65zxkwrxq-python3-3.11.9/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) ``` That's due to this check in cli.py: https://github.com/fzakaria/nix-auto-follow/blob/main/src/nix_auto_follow/cli.py#L196 - if the tool is invoked outside of a terminal, it ignores the file passed (or defaulted) on the CLI and just guesses that you want to read from stdin instead. I had to do this to work around that issue in github actions: ```yaml - run: nix run github:fzakaria/nix-auto-follow -- -i flake.lock < flake.lock name: Re-follow flake inputs ``` ...which feels unfortunate.
关闭于 2024-08-21 3 条评论