Fix for Pre-commit error on Ubuntu: "Illegal option -o pipefail"

Nishantsinghhhhhh

New member
I encountered an error while trying to commit on Ubuntu:

.husky/pre-commit: 2: set: Illegal option -o pipefail<br>husky - pre-commit script failed (code 2)<br>

The Issue:The .husky/pre-commit script uses set -o pipefail, which is a Bash feature. However, the file's header (#!/usr/bin/env sh) forces it to run using sh (which is Dash on Ubuntu). Dash does not support pipefail, causing the crash.

Is anybody else facing this same error, or is it just happening on my setup?
1768999897864.webp
 
Hi
Yes, this change is needed.

In #6317, we introduced `set -o pipefail` to improve reliability. On Ubuntu, `/bin/sh` points to `dash`, which does not support pipefail, causing failures. Because of this, the scripts need to explicitly use Bash.

I’m currently working on #6318, which migrates all Husky scripts to #!/usr/bin/env bash and fixes this issue fully. If you can wait, that PR will resolve it cleanly.

As a temporary workaround, you can locally change:

#!/usr/bin/env sh to #!/usr/bin/env bash
 
Back
Top