question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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

Screen Shot 2021-01-04 at 9 38 07 PM

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:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arcaniscommented, Jan 5, 2021

Perhaps it would be better to generate the diff in JS or not depend on git to do it since it may vary from OS to OS?

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.

0reactions
niieanicommented, Jan 5, 2021

Funny thing is, I had git installed via brew, it’s just that it wasn’t set as the first one in PATH. Running brew 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found