Search code examples
flutterhookatlassian-sourcetree

Lefthook error: flutter command not found


I switched from GitHub Desktop to Sourcetree due to some missing feature.

On my flutter project, I installed LeftHook to execute a linter when someone commits something. On GitHub Desktop, Lefthook works well, but when I try to commit from SourceTree, the error sh: flutter: command not found

Error

I can't understand why. The flutter SDK path is set globally correctly (i can use flutter commands in every terminal)


Solution

  • Problem solved!

    Seems like that Sourcetree isn't capable to access to the PATH in witch flutter is contained (the one added in the file .zshrc). So the solution is to add the export in every hook that lefthook uses, something like this:

    #!/bin/sh
    
    export PATH="$PATH:/Users/.../flutter/bin"
    
    if [ "$LEFTHOOK" = "0" ]; then
    ...