GITLAB_HOST variable ignored when using the glab auth status command

Checklist

  • I'm using the latest version of the extension (Run glab --version)
    • Extension version: 1.78.3
  • Operating system and version: Ubuntu 24.4
  • Gitlab.com or self-managed instance? self managed but this affects both
  • GitLab version (if self-managed) 18.5.1
  • I have performed glab auth status to check for authentication issues
  • Run the command in debug mode (like DEBUG=true glab mr list) and attach any useful output

Summary

export GITLAB_HOST=sourcery.assaabloy.net && glab auth status

gitlab.com
  x gitlab.com: API call failed: GET https://gitlab.com/api/v4/user: 401 {message: 401 Unauthorized}
  ✓ Git operations for gitlab.com configured to use ssh protocol.
  ✓ API calls for gitlab.com are made over https protocol.
  ✓ REST API Endpoint: https://gitlab.com/api/v4/
  ✓ GraphQL Endpoint: https://gitlab.com/api/graphql/
  ✓ Token found: **************************
servername.domain.net
  ✓ Logged in to servername.domain.net as jamnel (GITLAB_TOKEN)
  ✓ Git operations for servername.domain.net configured to use https protocol.
  ✓ API calls for servername.domain.net are made over https protocol.
  ✓ REST API Endpoint: https://servername.domain.net/api/v4/
  ✓ GraphQL Endpoint: https://servername.domain.net/api/graphql/
  ✓ Token found: **************************

! One of GITLAB_TOKEN, GITLAB_ACCESS_TOKEN, OAUTH_TOKEN environment variables is set. It will be used for all authentication.
          
   ERROR  
          
 could not authenticate to one or more of the configured GitLab instances..

❯ glab auth status --hostname servername.domain.net
servername.domain.net
  ✓ Logged in to servername.domain.net as jamnel (GITLAB_TOKEN)
  ✓ Git operations for servername.domain.net configured to use https protocol.
  ✓ API calls for servername.domain.net are made over https protocol.
  ✓ REST API Endpoint: https://servername.domain.net/api/v4/
  ✓ GraphQL Endpoint: https://servername.domain.net/api/graphql/
  ✓ Token found: **************************

! One of GITLAB_TOKEN, GITLAB_ACCESS_TOKEN, OAUTH_TOKEN environment variables is set. It will be used for all authentication.
                                     

Environment

  • OS: Linux 6.14.0-35-generic x86_64
  • SHELL: /bin/bash
  • TERM: xterm-256color
  • GLAB: 1.78.3

Other:

Steps to reproduce

Provided in my above example.

What is the current bug behavior?

Use the standard GITLAB_HOST environment variable to specify which host you are interacting with. And it gets ignored by the auth status command, and the command returns an error, even when the host and authentication are valid, since it checks gitlab.com as well.

What is the expected correct behavior?

Set GITLAB_HOST and GITLAB_TOKEN. Run glab auth status and it behanves like glab auth status --hostname $GITLAB_HOST

Relevant logs and/or screenshots

https://gitlab.com/gitlab-org/cli/-/blob/main/README.md#L316

Possible fixes