Skip to content

fix: enrich the notLoggedInMessage error message with the full path to the coder #17715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
enrich the "not logged in" error message with the full path to the coder
executable

Signed-off-by: Callum Styan <callumstyan@gmail.com>
  • Loading branch information
cstyan committed May 8, 2025
commit 730b5ddfe3cc8fd2cd8b330c4ea3665a2ac4aac2
8 changes: 6 additions & 2 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const (
varDisableDirect = "disable-direct-connections"
varDisableNetworkTelemetry = "disable-network-telemetry"

notLoggedInMessage = "You are not logged in. Try logging in using 'coder login <url>'."
notLoggedInMessage = "You are not logged in. Try logging in using '%s login <url>'."

envNoVersionCheck = "CODER_NO_VERSION_WARNING"
envNoFeatureWarning = "CODER_NO_FEATURE_WARNING"
Expand Down Expand Up @@ -534,7 +534,11 @@ func (r *RootCmd) InitClient(client *codersdk.Client) serpent.MiddlewareFunc {
rawURL, err := conf.URL().Read()
// If the configuration files are absent, the user is logged out
if os.IsNotExist(err) {
return xerrors.New(notLoggedInMessage)
binPath, err := os.Executable()
if err != nil {
binPath = "coder"
}
return xerrors.Errorf(notLoggedInMessage, binPath)
}
if err != nil {
return err
Expand Down