Open purkhusid opened 2 years ago
@purkhusid this is indeed a confusing error message. I suspect this happens due to failing gh codespace select
GH CLI command. Mind trying to run gh-net
with a Codespace name to confirm that?
For instance:
gh net --codespace legomushroom-utils-rs-9qpr7qvcxwqr
Hi, I face the same issue. In my environment, gh cs select
works fine but gh net --codespace xxxx
exit with the same error and backtraces.
❯ gh cs select
? Choose codespace: komazarari/foobar (master*): refactored guide
komazarari-refactored-guide-wv7gp6967jfg6rx
❯ RUST_BACKTRACE=full gh net --codespace komazarari-refactored-guide-wv7gp6967jfg6rx
No such file or directory (os error 2)
thread 'main' panicked at 'byte index 50 is out of bounds of `[io-error] No such file or directory (os error 2)`', library/core/src/str/mod.rs:107:9
stack backtrace:
...
( all backtraces are the same except hex addresses )
❯ uname -srmo && grep VERSION= /etc/os-release && gh version && gh extension list
Linux 5.15.74.2-microsoft-standard-WSL2 x86_64 GNU/Linux
VERSION="20.04.5 LTS (Focal Fossa)"
gh version 2.20.2 (2022-11-15)
https://github.com/cli/cli/releases/tag/v2.20.2
gh net github/gh-net v0.12.4
@komazarari @purkhusid the issue mind be is that the Linux will use root
user for gh-net
(we esalate to root
automatically to be able to bind to network interfaces) and gh-net
is not authenticated for the root
user (to check run sudo gh auth status
).
To fix this:
gh auth status -t
and copy token from the output.root
user with the token: echo {TOKEN} | sudo gh auth login --with-token
gh net
again.Sorry for the confusing, we should definitely improve the error message in this case. I will keep this issue open to track the work to be done for that.
Related issue on the GH CLI side: https://github.com/cli/cli/issues/5456
@legomushroom Thank you for your clear explanation. My environment needed a few additional fixes, but finally, I got them working fine.
In my case, I installed gh
with linuxbrew, so I need to install the gh-net extension for the root
as well.
❯ sudo /home/linuxbrew/.linuxbrew/bin/gh auth status
github.com
✓ Logged in to github.com as komazarari (oauth_token)
✓ Git operations for github.com configured to use https protocol.
✓ Token: *******************
❯ sudo /home/linuxbrew/.linuxbrew/bin/gh net'
unknown command "net" for "gh"
Usage: gh <command> <subcommand> [flags]
Available commands:
alias
api
...
...
❯ gh extension list
gh net github/gh-net v0.12.4
❯ sudo /home/linuxbrew/.linuxbrew/bin/gh extension list
no installed extensions found
So I installed the extension for root
user as followings, then it worked well. Thank you 😃
❯ sudo /home/linuxbrew/.linuxbrew/bin/gh extension install github/gh-net'
✓ Installed extension github/gh-net
❯ sudo bash -c 'PATH=$PATH:/home/linuxbrew/.linuxbrew/bin gh net'
? Choose codespace: [Use arrows to move, type to filter]
> komazarari/foobar (master*): refactored guide
Yes, it works now. Another tip to troubleshoot, if needed:
sudo -i
as then, after some auth login tricks:
~# gh auth status
github.com
✓ Logged in to github.com as [....] (/root/.config/gh/hosts.yml)
✓ Git operations for github.com configured to use https protocol.
✓ Token: ghp_************************************
✓ Token scopes: admin:org, admin:public_key, codespace, delete:packages, delete_repo, notifications, project, read:ssh_signing_key, read:user, repo, workflow, write:packages
~# gh extension install github/gh-net
✓ Installed extension github/gh-net
etc.
If I run the following command:
I get the following output:
gh
version: 2.16.0gh-net
version: 0.12.4