{"record":{"id":"7c2bccf168285055","repo":"mislav/hub","slug":"error-couldn-t-detect-shell-type-please-specify","errorCode":null,"errorMessage":"Error: couldn't detect shell type. Please specify your shell with `%s`","messagePattern":"Error: couldn't detect shell type\\. Please specify your shell with `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/alias.go","lineNumber":50,"sourceCode":"func init() {\n\tCmdRunner.Use(cmdAlias)\n}\n\nfunc alias(command *Command, args *Args) {\n\tvar shell string\n\tif args.ParamsSize() > 0 {\n\t\tshell = args.FirstParam()\n\t} else {\n\t\tshell = os.Getenv(\"SHELL\")\n\t}\n\n\tflagAliasScript := args.Flag.Bool(\"-s\")\n\tif shell == \"\" {\n\t\tcmd := \"hub alias <shell>\"\n\t\tif flagAliasScript {\n\t\t\tcmd = \"hub alias -s <shell>\"\n\t\t}\n\t\tutils.Check(fmt.Errorf(\"Error: couldn't detect shell type. Please specify your shell with `%s`\", cmd))\n\t}\n\n\tshells := []string{\"bash\", \"zsh\", \"sh\", \"ksh\", \"csh\", \"tcsh\", \"fish\", \"rc\"}\n\tshell = filepath.Base(shell)\n\tvar validShell bool\n\tfor _, s := range shells {\n\t\tif s == shell {\n\t\t\tvalidShell = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !validShell {\n\t\terr := fmt.Errorf(\"hub alias: unsupported shell\\nsupported shells: %s\", strings.Join(shells, \" \"))\n\t\tutils.Check(err)\n\t}\n\n\tif flagAliasScript {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/alias.go#L32-L68","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\neval \"$(hub alias -s)\"   # fails when SHELL is empty\n// after\neval \"$(hub alias -s zsh)\"","handlingStrategy":"validation","validationCode":"if [ -z \"$SHELL\" ]; then\n  eval \"$(hub alias -s bash)\"   # pass shell explicitly when SHELL is unset\nelse\n  eval \"$(hub alias -s \"$(basename \"$SHELL\")\")\"\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["shell","configuration","cli"],"backgroundTag":"shell-not-detected","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}