mislav/hub · error
Error: couldn't detect shell type. Please specify your shell
Error message
Error: couldn't detect shell type. Please specify your shell with `%s`
What it means
`hub alias` prints a shell snippet that aliases `git` to `hub`. It detects the current shell from $SHELL (or $ZSH_VERSION/$BASH_VERSION style hints); if detection yields an empty string, it calls utils.Check with this error, telling you to pass the shell explicitly. utils.Check prints the message and exits, so this is fatal.
Source
Thrown at commands/alias.go:50
func init() {
CmdRunner.Use(cmdAlias)
}
func alias(command *Command, args *Args) {
var shell string
if args.ParamsSize() > 0 {
shell = args.FirstParam()
} else {
shell = os.Getenv("SHELL")
}
flagAliasScript := args.Flag.Bool("-s")
if shell == "" {
cmd := "hub alias <shell>"
if flagAliasScript {
cmd = "hub alias -s <shell>"
}
utils.Check(fmt.Errorf("Error: couldn't detect shell type. Please specify your shell with `%s`", cmd))
}
shells := []string{"bash", "zsh", "sh", "ksh", "csh", "tcsh", "fish", "rc"}
shell = filepath.Base(shell)
var validShell bool
for _, s := range shells {
if s == shell {
validShell = true
break
}
}
if !validShell {
err := fmt.Errorf("hub alias: unsupported shell\nsupported shells: %s", strings.Join(shells, " "))
utils.Check(err)
}
if flagAliasScript {View on GitHub (pinned to 5c547ed804)
Solutions
- Pass the shell explicitly: `hub alias bash` or `hub alias -s zsh` as the error message suggests.
- Export SHELL in the environment: export SHELL=$(basename $SHELL) before running hub alias.
- If using an unsupported shell, write the alias manually using the closest supported output (bash/zsh/fish) as a template.
Example fix
// before eval "$(hub alias -s)" # fails when SHELL is empty // after eval "$(hub alias -s zsh)"
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$SHELL" ]; then eval "$(hub alias -s bash)" # pass shell explicitly when SHELL is unset else eval "$(hub alias -s "$(basename "$SHELL")")" fi
Prevention
- Always pass the shell explicitly in scripts: hub alias -s zsh.
- Ensure SHELL is exported in non-interactive environments.
- Pin the alias generation to a known shell in dotfiles installers.
When it happens
Trigger: Running `hub alias` (or `hub alias -s`) non-interactively — e.g. in scripts, cron, CI, or eval "$(hub alias -s)" contexts — where $SHELL is unset/empty so no shell type can be inferred.
Common situations: Sourcing the alias snippet from a script where SHELL isn't exported; running under shells hub can't infer (nushell, elvish, xonsh); cron jobs lacking the interactive env; Windows environments without SHELL.
Related errors
- hub alias: unsupported shell supported shells: %s
- alias starting with ! can't be split
- Please set $BROWSER to a web launcher
- Unsupported flag -b when checking out pull request
- Unsupported flag --orphan when checking out pull request
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/7c2bccf168285055.
Report an issue: GitHub.