{"record":{"id":"9ba6f76c5b9f001e","repo":"abpframework/abp","slug":"cannot-determine-shell-command-for-this-os-runnin","errorCode":null,"errorMessage":"Cannot determine shell command for this OS! Running on OS: {System.Runtime.InteropServices.RuntimeInformation.OSDescription} | OS Architecture: {System.Runtime.InteropServices.RuntimeInformation.OSArchitecture} | Framework: {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} | Process Architecture{System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}","messagePattern":"Cannot determine shell command for this OS! Running on OS: (.+?) \\| OS Architecture: (.+?) \\| Framework: (.+?) \\| Process Architecture(.+?)","errorType":"exception","errorClass":"AbpException","httpStatus":null,"severity":"critical","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs","lineNumber":207,"sourceCode":"    {\n        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))\n        {\n            //Windows\n            return \"cmd.exe\";\n        }\n\n        //Linux or OSX\n        if (File.Exists(\"/bin/bash\"))\n        {\n            return \"/bin/bash\";\n        }\n\n        if (File.Exists(\"/bin/sh\"))\n        {\n            return \"/bin/sh\"; //some Linux distributions like Alpine doesn't have bash\n        }\n\n        throw new AbpException($\"Cannot determine shell command for this OS! \" +\n                               $\"Running on OS: {System.Runtime.InteropServices.RuntimeInformation.OSDescription} | \" +\n                               $\"OS Architecture: {System.Runtime.InteropServices.RuntimeInformation.OSArchitecture} | \" +\n                               $\"Framework: {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} | \" +\n                               $\"Process Architecture{System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}\");\n    }\n\n    private void HideNewCommandWindow(ProcessStartInfo procStartInfo)\n    {\n        procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;\n        procStartInfo.CreateNoWindow = true;\n    }\n}\n","sourceCodeStart":189,"sourceCodeEnd":220,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs#L189-L220","documentation":"Thrown by CmdHelper.GetFileName() when the CLI needs to launch a shell process but the current OS is not Windows and neither /bin/bash nor /bin/sh exists on disk. This AbpException includes OS/architecture/framework details to aid diagnosis. It is a hard environment-compatibility failure: the CLI cannot run npm/other shell commands without a shell binary.","triggerScenarios":"Running the ABP CLI (which shells out to npm/yarn/dotnet) on a non-Windows, non-OSX system where both /bin/bash and /bin/sh are absent — e.g. a heavily stripped container or an unusual Unix where the POSIX shell lives elsewhere (e.g. /usr/bin/sh only).","commonSituations":"Minimal Docker images that lack bash and link sh at a non-standard path; chroot/sandbox environments without a shell bind-mounted in; running under a custom .NET runtime host that misreports the OS so the Windows branch is skipped.","solutions":["Install or expose a shell: add bash (apk add bash / apt-get install bash) or ensure /bin/sh exists; symlink /usr/bin/sh to /bin/sh if needed.","If using a minimal base image, switch to one that ships a POSIX shell (e.g. debian-slim instead of a from-scratch image).","Verify RuntimeInformation.IsOSPlatform(OSPlatform.Windows) is not being incorrectly skipped; on true Windows this branch should never run.","Avoid invoking CLI commands that require npm/yarn in the stripped environment, or pre-build the assets where a shell is available."],"exampleFix":"// before — running in a from-scratch/alpine image without bash\n// after — in the Dockerfile\nRUN apk add --no-cache bash\n# or ensure /bin/sh exists: alpine ships busybox ash at /bin/sh by default,\n# so confirm the path rather than relying on /usr/bin/sh","handlingStrategy":"validation","validationCode":"// Pre-flight shell availability check (non-Windows) before running CLI subcommands\nif (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))\n{\n    if (!File.Exists(\"/bin/bash\") && !File.Exists(\"/bin/sh\"))\n        throw new InvalidOperationException(\"No shell found at /bin/bash or /bin/sh; install bash or link sh.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Base CLI images on debian-slim or alpine+bash so a shell is always present.","In Dockerfiles, RUN apk add bash or apt-get install bash before invoking the CLI.","Keep CLI invocations that shell out to npm on hosts where /bin/sh exists."],"tags":["abp-cli","environment","shell","platform","docker"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}