glab cli environment variable deprecation (GLAB_ prefix) feedback issue
Summary
This issue is used to track the progress of deprecating current environment variables that are used by the glab cli.
Starting with glab version v2.0.0 environment variables used by glab should be prefixed with GLAB_, namely:
GLAMOUR_STYLEDEBUGNO_PROMPTFORCE_HYPERLINKS
The following environment variables that will continue working as before are:
BROWSER- the process spawned by the command to start the browser inherits the environment variables, so it doesn't make sense to haveGLAB_BROWSERto rename it toBROWSERNO_COLOR- the tool follows the https://no-color.org/ specificationVISUAL- considered one of the default values nowadaysEDITOR- considered one of the default values nowadays
Until then both versions of the environment variables will work. To give an example:
❯ GLAB_NO_PROMPT=true ./bin/glab mr create
ERROR: --title or --fill required for non-interactive mode.
Try 'glab mr create --help' for more information.
❯ NO_PROMPT=true ./bin/glab mr create
DEPRECATION WARNING: The environment variable NO_PROMPT has been deprecated and will be removed in future releases. Use GLAB_NO_PROMPT instead.
ERROR: --title or --fill required for non-interactive mode.
Try 'glab mr create --help' for more information.To give another couple of examples:
❯ GLAMOUR_STYLE=light ./bin/glab issue view 7928 | head -3
DEPRECATION WARNING: The environment variable GLAMOUR_STYLE has been deprecated and will be removed in future releases. Use GLAB_GLAMOUR_STYLE instead.
title: glab release fails with 422 when using --publish-to-catalog
state: open
❯ GLAB_GLAMOUR_STYLE=light ./bin/glab issue view 7928 | head -3
title: glab release fails with 422 when using --publish-to-catalog
state: open
author: ignacio.piquerasBelow is the list of environment variables and their new names:
| before | after |
|---|---|
GLAMOUR_STYLE |
GLAB_GLAMOUR_STYLE |
DEBUG |
GLAB_DEBUG |
NO_PROMPT |
GLAB_NO_PROMPT |
FORCE_HYPERLINKS |
GLAB_FORCE_HYPERLINKS |
Implementation plan
Note: This plan was drafted during an AI-assisted triage of the backlog and has not been validated by a maintainer. Treat it as a starting point: file paths, line numbers, and the approach may need adjusting.
- In
internal/run/run.go, add an unexporteddebugEnabled()helper next tocmdWithStderr. It should return true when eitherGLAB_DEBUGorDEBUGparses as a truthy bool viastrconv.ParseBool, checkingGLAB_DEBUGfirst. Note thatinternal/utilsimportsinternal/run, soruncannot callutils.IsEnvVarEnabled: keep the helper local to the package. - When only the legacy
DEBUGis set, printDEPRECATION WARNING: The environment variable DEBUG has been deprecated and will be removed in future releases. Use GLAB_DEBUG instead.toos.Stderr, guarded by a package-levelsync.Onceso a command that shells out to Git repeatedly warns once rather than per invocation. Match the wording ininternal/utils/utils.go:233. - Replace both inline
strconv.ParseBool(os.Getenv("DEBUG"))checks, incmdWithStderr.Output(internal/run/run.go:39) andcmdWithStderr.Run(internal/run/run.go:55), with a call to the new helper. - Add
internal/run/run_test.go(the package has no test file yet). Uset.Setenvto cover four cases:GLAB_DEBUG=truetraces,DEBUG=truetraces and warns, both set warns once, neither set is silent. Assert on a capturedos.Stderr, following the stderr-capture pattern ininternal/commands/root_test.go:52(TestDeprecationWarningStaysOffStdOut). - No help text changes, so
make gen-docsis not needed.docs/source/configuration.md:134already claimsGLAB_DEBUGcovers underlying Git commands, and this change makes that true. - Run
go test ./internal/run/... ./internal/utils/... ./cmd/glab/...andmake lint.
Edited by Kai Armstrong