[Bug] patch-commit does not return any output/error
See original GitHub issue- I’d be willing to implement a fix
Describe the bug
Running yarn patch-commit /path/to/generated/dir
returns without output nor does it generate any file.
To Reproduce
yarn init --yes
yarn add slate-react
yarn patch slate-react
# make some changes to the package in the output directory
yarn patch-commit $dir
This returns no output. For some reason, it does not reproduce in sherlock (Sherlock gives output), but I can consistently reproduce locally.
Tried latest version and built from master. Tried Node 12, 14 and 15.
Reproduction
const {writeFile} = require('fs').promises
await writeFile(`./.yarnrc.yml`, 'nodeLinker: node-modules')
await yarn(`init`, `--yes`);
await yarn(`add`, `slate-react`);
const output1 = await yarn(`patch`, `slate-react`);
const [, line] = output1.split('\n')
const [, dir] = line.split('folder: ')
await writeFile(`${dir}/dist/index.es.js`, '// some changes')
const output2 = await yarn(`patch-commit`, dir);
expect(output2).not.toBe('')
Screenshots

Environment if relevant (please complete the following information):
- OS: OSX 10.15.7 [e.g. OSX, Linux, Windows, …]
- Node version: Tried Node 12, 14 and 15. [e.g. 8.15.0, 10.15.1, …]
- Yarn version: Tried latest and from master [e.g. 2.4.0, …]
Additional context
As an aside, the output from the command that sherlock gives is not consistent with the documentation, which states:
This will turn the folder passed in parameter into a patchfile
It actually doesn’t generate a patchfile, but outputs it into stdout.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Git apply patch fails silently (no errors but nothing happens)
git apply will fail to do anything when used within a local checkout of a git repository (other than the one for the...
Read more >git unadd changes lost if hook fails on windows #570 - GitHub
it doesn't work. but I found the problem. whether I set the whitespace( cr-at-eol or true ), git diff output to a file...
Read more >git-apply Documentation - Git
Don't return error for patches containing no diff. This includes empty patches and patches with commit text only. CONFIGURATION. Everything below this line...
Read more >git-apply(1) - Arch manual pages
This command applies the patch but does not create a commit. Use git-am(1) to create commits from patches generated by git-format-patch(1) and/or received ......
Read more >Rerolling patches | Working with patches - Drupal
Reasons that a patch may need to be rerolled: Commits from other issues and patches have been made in the same area of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh interesting - I think it’s better to keep using git (generating patchfiles is very tricky, especially if it needs to be done fast), but we certainly can return a proper error message (we can even detect the flag support using stderr and explain how to fix it, for example via
Please install git via brew
etc).Regarding your initial issue, the documentation is indeed unclear, but the current behavior is intended: Yarn is expected to generate the output but not the file. You can then redirect it to wherever you want. We purposefully don’t make assumptions regarding the filesystem at the moment. It’s often mentioned as something we can improve though, so I’d be open to hear about what we could do better.
Funny thing is, I had
git
installed viabrew
, it’s just that it wasn’t set as the first one in PATH. Runningbrew link --overwrite git
fixed it. I’ve clarified the message and force-pushed the update to the linked PR. It doesn’t specify brew, but should be enough to understand what is the culprit.