Closed julien closed 4 years ago
@julien thanks for reporting this. We added a feature recently to open your editor when you omit --title
and --description
. We are using your OS's temp directory, but it looks like it would require you to use sudo.
Here are some workarounds until we can solve this better:
In your ~/.gh.json
file add "use_editor": false
.
OR
sudo gh pr -s SOME_GITHUB_USERNAME
OR
add the title and description
gh pr -s SOME_GITHUB_USERNAME -t "hey" -D "description"
OR make your /tmp
dir writable.
We should probably list these options instead of a fatal error.
Thanks for the quick reply @protoEvangelion.
I'll add "use_editor": false
to ~/.gh.json
but I still think this issue should be fixed and not closed, because I can actually write to my /tmp
directory, and lots of programs I use on a daily basis do that as well without crashing (it's a standard feature after all).
As an example
const fs = require("fs");
const os = require("os");
const path = require("path");
fs.writeFile(
path.join(os.tmpdir(), "foo.txt"),
"This is some text ...\n",
err => { err && console.error(err) }
);
Works fine on this machine (the file foo.txt is
created in /tmp
with the content I provided)
The fact that it's JS doesn't really matter, this could be a bash script or a compiled C program and it would have the same result.
Thanks for the extra info @julien that helps a lot as I can't repro on my machine!
Could you replace https://github.com/node-gh/gh/blob/master/src/utils.ts#L78 with writeFileSync(
${os.tmpdir()}-${filename}, msg)
and let me know if that works?
If you don't want to build the project you can just find that line and replace it in your node_modules in the utils.js file:
Hey @protoEvangelion,
Thanks, I think your solution needs some modifications, but it's pretty easy to fix
${os.tmpdir()}-${filename}
Is going to return something like
/tmp-temp-gh-pr-title.txt
Which is not what you want (notice the -
being used as the path separator)
I usually use the path
module to construct paths, because it can come in handy when dealing with this kind of thing or having to support different OS's
In my case I used:
path.join(os.tmpdir(), fileName);
Just make sure both path
and os
modules are required because they aren't at the moment.
The second thing that was failing was getting the "editor".
The program tries to get the editor with:
const editor = exec.spawnSync('git', ['config', '--global', 'core.editor']).stdout;
In my case (I try to add the bare minimum configuration)
git config --global core.editor
Doesn't return anything. I usually don't set it and rely on programs to be "smart" enough to read $EDITOR
or $VISUAL
, and that's what git does too apparently.
But once I configured that, it worked.
I'd still try to read $EDITOR
or $VISUAL
which should be easy to get with process.env
and maybe as a "fallback" try the current solution.
Awesome suggestions @julien 🎉 Thank you again for the extra details & ideas.
I will give that a try unless you would like to send a PR for it 😄
@protoEvangelion it's ok I figured what was going on.
@all-contributors please add @julien for bug,code
@protoEvangelion
I couldn't determine any contributions to add, did you specify any contributions? Please make sure to use valid contribution names.
@all-contributors please add @julien for bug code
@protoEvangelion
I've put up a pull request to add @julien! :tada:
:tada: This issue has been resolved in version 2.8.3 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Version number 2.8.1
Describe the bug
After installing the package via
npm i -g gh
A warning is shown
When trying to run
gh pr -s SOME_GITHUB_USERNAME
an error is thrown(Obviously SOME_GITHUB_USERNAME is a real username on GitHub, I just didn't want to include it in the bug report for privacy reasons.)
To Reproduce
Please see description above
Expected behavior
I expect this package to work as intended,
gh pr -s SOME_GITHUB_USERNAME
should submit the pull request to SOME_GITHUB_USERNAME on Github.Screenshots
Additional context