Skip to content

"cygpath: command not found" when commiting to branch #10326

Closed

Description

@zedd3v

"cygpath: command not found" when commiting to branch

Github desktop version: 2.5.3
OS: Windows 10

Full error:

Commit failed - exit code 1 received, with output: '/c/Users/karlo/AppData/Roaming/npm/yarn: line 5: cygpath: command not found
internal/modules/cjs/loader.js:1032
throw err;
^

Error: Cannot find module 'C:\Users\karlo\AppData\Local\GitHubDesktop\app-2.5.3\resources\app\git\node_modules\yarn\bin\yarn.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}'

Activity

  1. tierninho commented on Aug 5, 2020

    @tierninho
    Contributor

    @zedd3v Thanks for the report. This looks like an error with your shell or path settings. Can you list your reproductions steps? What shell are you using in Desktop -- see the Options settings? And share your logs from that day? See the Help menu in Desktop for the logs.

    The cygpath program is part of the Git for Windows installation. Please ensure that you have git installed from https://git-scm.com/download/win. In general you should be using the system installed Git (i.e. Git for Windows).

  2. added
    more-info-needed
    on Aug 5, 2020
  3. tierninho commented on Aug 11, 2020

    @tierninho
    Contributor

    @zedd3v As we have not heard back from you on this issue, we are closing it for now. Should you have any more details or questions, please reach out and we will be happy to help. Thank you.

  4. donna-marijne commented on Oct 20, 2020

    @donna-marijne

    I believe that the problem is due to the following code from yarn's bootstrap script on Windows:

    case `uname` in
        *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
    esac

    So if yarn is run as part of a git hook, this will be executed in Desktop's own bundled MINGW environment, which (unlike the one bundled with Git for Windows) does not include the cygpath utility.

  5. owenashurst commented on Nov 6, 2020

    @owenashurst

    I believe that the problem is due to the following code from yarn's bootstrap script on Windows:

    case `uname` in
        *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
    esac

    So if yarn is run as part of a git hook, this will be executed in Desktop's own bundled MINGW environment, which (unlike the one bundled with Git for Windows) does not include the cygpath utility.

    Is there a way to force github desktop to use the Git for Windows version instead?

  6. rletsin commented on Nov 17, 2020

    @rletsin

    @tierninho
    I have the same issue.
    I am using GitHub Desktop with few repositories, but issue appears only on front-end monorepo. We are using husky and yarnhook inside it, so I suppose these may cause this error. Happens on every checkout, push, merge etc. and it's pretty annoying.
    We use pnpm to manage our monorepo and this husky config inside package.json:
    "husky": { "hooks": { "pre-push": "pnpm run prepush", "post-checkout": "yarnhook", "post-merge": "yarnhook", "post-rewrite": "yarnhook" } }

    OS: Windows 10
    GitHub Desktop: version up to 2.6.0
    git for Windows: 2.29.2
    Using git bash shell
    Node: 10.23.0
    npm: 6.14.8
    pnpm: 5.12.0

  7. RyanGuild-TF commented on Nov 30, 2020

    @RyanGuild-TF

    I also have been having this issue in a number of repositories. Love github desktop for visualizing commits but I have never been able to commit through the GUI.

    npm global installs are in my PATH. i.e. yarn can be run in bash

    very same error

    Commit failed - exit code 1 received, with output: '/c/Users/ryan.guild/AppData/Roaming/npm/yarn: line 5: cygpath: command not found
    internal/modules/cjs/loader.js:1032
    throw err;
    ^

    Error: Cannot find module 'C:\Users\ryan.guild\AppData\Local\GitHubDesktop\app-2.6.0\resources\app\git\node_modules\yarn\bin\yarn.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
    code: 'MODULE_NOT_FOUND',
    requireStack: []
    }'

    OS: Windows 10
    GitHub Desktop: version up to 2.6.0
    git version: 2.27.0.windows.1
    Using git bash shell
    Node: >=14
    npm: 6.14.9
    pnpm: ??? - never heard of this

  8. Druegor commented on Dec 18, 2020

    @Druegor

    @RyanGuild-TF I was actually able to make this work by manually copying the .../AppData/Roaming/npm/node_modules into the ...AppData\Local\GitHubDesktop\app-2.6.0\resources\app\git\ folder. Wish I could figure out a better way to make it work but that is what I had to resort to.

  9. JMaio commented on Dec 25, 2020

    @JMaio

    I'm having the same issue with GitHub Desktop, and can confirm @donna-marijne's reply that the issue seems to be with the yarn bootstrap script:

    case `uname` in
        *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
    esac

    This is only happening in GitHub Desktop's bundled MINGW (but not system Git Bash), and according to @steveward, GitHub Desktop ships with an internal version of Git which, again, seems to not include the cygpath utility.

    Removing this case from the script lets the configured hooks run correctly in GitHub Desktop without affecting other terminals (probably).
    Looks like either GitHub Desktop's MINGW should include cygpath, or maybe yarn should not rely on this command...

    My config:

    OS Windows 10, 20H2 (build 19042.685)
    GitHub Desktop 2.6.1
    Git for Windows 2.29.2.windows.3
    node v15.5.0
    npm 7.3.0
    yarn 1.22.10 (global) / 2.4.0 (project)
    husky v4.3.6

    (using yarn 2 with PnP)

  10. added a commit that references this issue on Dec 25, 2020
  11. mwittmann commented on Jul 20, 2021

    @mwittmann

    I had this issue using pnpm as the package manager in one of my git repos. I added C:\Program Files\Git\usr\bin which contains cygpath.exe to my PATH environment variable, and that resolved the issue.

  12. meena-erian commented on Sep 15, 2021

    @meena-erian

    I had the same problem and it turns out it was because of a pre-commit script.

    In case you're having the same problem, you can either commit from the command line while skipping the pre-commit script
    git commit -m "fixed something" --no-verify

    or if you don't need the pre-commit script, you can delete the file YourRepository/.git/hooks/pre-commit

  13. leopucci commented on Sep 20, 2021

    @leopucci

    I had this issue using pnpm as the package manager in one of my git repos. I added C:\Program Files\Git\usr\bin which contains cygpath.exe to my PATH environment variable, and that resolved the issue.

    This caused me another problem

    0 [main] cygpath (6136) C:\Program Files\Git\usr\bin\cygpath.exe: *** fatal error - cygheap base mismatch detected - 0x18034C408/0x180347408. This problem is probably due to using incompatible versions of the cygwin DLL. Search for cygwin1.dll using the Windows Start->Find/Search facility and delete all but the most recent version. The most recent version *should* reside in x:\cygwin\bin, where 'x' is the drive on which you have installed the cygwin distribution. Rebooting is also suggested if you are unable to find another cygwin DLL. internal/modules/cjs/loader.js:892 throw err; ^

  14. leopucci commented on Sep 20, 2021

    @leopucci

    @RyanGuild-TF I was actually able to make this work by manually copying the .../AppData/Roaming/npm/node_modules into the ...AppData\Local\GitHubDesktop\app-2.6.0\resources\app\git\ folder. Wish I could figure out a better way to make it work but that is what I had to resort to.

    This workaround solved for me. Now the pre-commit hook can run yarn

  15. 7 remaining items

  16. Geerodge commented on Dec 6, 2022

    @Geerodge

    This works, thank you. Remember to restart Git Desktop after adding to path environment variable.

  17. octopushugger commented on Dec 10, 2022

    @octopushugger

    Still having this issue on 3.1.2. Really didn't wanna add C:\Program Files\Git\usr\bin to path but that was the only method that fixed it for me.

  18. viniciusdalastra commented on Jan 5, 2023

    @viniciusdalastra

    I fixed moving the cygpath.exe to "%AppData%\Local\GitHubDesktop\app-3.1.3\resources\app\git\usr\bin"

    This error occurred when i updated the version.

  19. juancolchete commented on Jan 29, 2023

    @juancolchete

    I had this issue using pnpm as the package manager in one of my git repos. I added C:\Program Files\Git\usr\bin which contains cygpath.exe to my PATH environment variable, and that resolved the issue.

    Worked for me also

  20. rettoua commented on Feb 10, 2023

    @rettoua

    Even though the issue is marked as closed the problem is still there. Copying node_module folder helped to solve the problem.

  21. mason369 commented on Mar 16, 2023

    @mason369

    The issue still reproduces. Version 3.2.0 (x64)

  22. SalmanTahir7 commented on Jul 24, 2023

    @SalmanTahir7

    Reopen this issue, it still persists no matter the update, I have to apply the same fix every time I try to commit something

  23. lunarmint commented on Aug 3, 2023

    @lunarmint

    I had this issue using pnpm as the package manager in one of my git repos. I added C:\Program Files\Git\usr\bin which contains cygpath.exe to my PATH environment variable, and that resolved the issue.

    Clean solution and worked for me, thanks!

  24. dennis-gonzales commented on Aug 7, 2023

    @dennis-gonzales

    Reopen this issue, it still persists no matter the update, I have to apply the same fix every time I try to commit something

    I agree, the accepted solution indeed works but at the end of the day it is just a workaround and not a permanent fix.

  25. pisolofin commented on Sep 7, 2023

    @pisolofin

    I had this issue using pnpm as the package manager in one of my git repos. I added C:\Program Files\Git\usr\bin which contains cygpath.exe to my PATH environment variable, and that resolved the issue.

    That resolve my issue in GitKraken, thanks :)

  26. larsdouweschuitema commented on Sep 20, 2023

    @larsdouweschuitema

    Add the following line to the .bashrc or .bash_profile file, replacing "C:/Program Files/Git/bin" with the actual path to your Git "bin" folder:

    export PATH=$PATH:"C:/Program Files/Git/bin"

    .bashr or . bash_profile can be located in your user folder "C:/Users/[name]".

    Make sure to reload your application. Whether that is Github Desktop, SourceTree, GitKraken or anything else.

  27. sathish099 commented on Nov 4, 2023

    @sathish099

    I had this issue using pnpm as the package manager in one of my git repos. I added C:\Program Files\Git\usr\bin which contains cygpath.exe to my PATH environment variable, and that resolved the issue.

    Yes it is working. but it takes more time a single line of code! why? @meena-erian

  28. DanielYamini commented on Nov 4, 2023

    @DanielYamini
  29. gbarros1994 commented on Jan 24, 2024

    @gbarros1994

    In my case, what resolved was changing the node version

  30. C0rn3j commented on Nov 21, 2024

    @C0rn3j

    Apparently I installed the WRONG git by using chocolatey -y git.

    winget install --id Git.Git -e --source winget resolved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    more-info-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions