node-gh / gh

(DEPRECATED) GitHub CLI made with NodeJS. Use the official https://cli.github.com/ instead.
http://nodegh.io
Other
1.71k stars 217 forks source link

gh is: Cannot read property 'login' of undefined #531

Closed speedplane closed 6 years ago

speedplane commented 6 years ago

I just installed gh and I immediately got the following error:

>gh is --verbose
DEBUG: ENOENT: no such file or directory, open 'C:\Users\mes65\[REDACTED]\.gh.json'
DEBUG: ENOENT: no such file or directory, open 'C:\Users\mes65\[REDACTED]\.gh.json'
DEBUG: spawnSync: git config --get remote.origin.url
DEBUG: spawnSync: git symbolic-ref --short HEAD
Listing open issues on speedplane/DocketAlarm
C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\lib\cmds\issue.js:461
                        '@' + issue.user.login + ' (' + logger.getDuration(issue.created_at) + ')'
                                         ^

TypeError: Cannot read property 'login' of undefined
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\lib\cmds\issue.js:461:42
    at Array.forEach (<anonymous>)
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\lib\cmds\issue.js:452:20
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\node_modules\async\lib\async.js:726:13
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\node_modules\async\lib\async.js:52:16
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\node_modules\async\lib\async.js:269:32
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\node_modules\async\lib\async.js:44:16
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\node_modules\async\lib\async.js:723:17
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\node_modules\async\lib\async.js:167:37
    at C:\Users\mes65\AppData\Roaming\npm\node_modules\gh\node_modules\github\api\v3.0.0\issues.js:127:17

Login info:

>gh user --verbose
DEBUG: ENOENT: no such file or directory, open 'C:\Users\mes65\[REDACTED]\.gh.json'
DEBUG: spawnSync: git config --get remote.origin.url
DEBUG: spawnSync: git symbolic-ref --short HEAD
You're logged in as speedplane

Version info:

>node --version
v8.9.4

>gh --version
gh 1.13.0

>npm list -g --depth=0 | grep gh
+-- gh@1.13.0

I tried uninstaling and reinstalling with npm uninstall -g gh && npm install -g gh but no luck, same error message.

ackalker commented 6 years ago

I do not have a fix for this issue (obviously an error like this shouldn't occur), but as a workaround you can try logging out and back in:

>gh user -L
>gh user -l

Running the second command, you will be asked for your Github username and password. This also has the nice side effect of creating a default .gh.json configuration file.

protoEvangelion commented 6 years ago

@speedplane Thanks for your patience and for bringing this to our attention :smile:

Just released a new version that should fix at least this portion of the error message:

DEBUG: ENOENT: no such file or directory, open 'C:\Users\mes65\[REDACTED]\.gh.json'

If it doesn't fix this error we will have to do some further debugging:

TypeError: Cannot read property 'login' of undefined

Could you try this new version 1.12.10 and let me know if this fixes your issue? Thanks!

protoEvangelion commented 6 years ago

After further investigation, this is actually the intended functionality and not a bug so I reverted the changes.

If we do not find the file we return the global config.

--verbose is more for internal debugging

Was there a reason you need to use the --verbose flag?

Closing for now unless you need some info provided by verbose that you can't otherwise get.