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

how to ensure using the correct gh #641

Closed rotty3000 closed 5 years ago

rotty3000 commented 5 years ago

How to solve the following scenario:

~]$ sudo npm i -g gh
npm WARN deprecated github@0.2.4: 'github' has been renamed to '@octokit/rest' (https://git.io/vNB11)
/usr/bin/gh -> /usr/lib/node_modules/gh/bin/gh.js
+ gh@1.17.3
updated 1 package in 5.231s
~]$ gh -v
gh 1.13.9
protoEvangelion commented 5 years ago

Hmm something seems off. I just tested it locally and all it does is run this function which reads the globally installed package.json:

Version.prototype.printVersion = function(pkg) {
    logger.log(`${pkg.name} ${pkg.version}`)
}

My globally installed package.json has the correct version. If you try this cat $(npm root -g)/gh/package.json | grep version what does it show?

rotty3000 commented 5 years ago
~]$ cat $(npm root -g)/gh/package.json | grep version
        "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
  "version": "1.17.3"
rotty3000 commented 5 years ago

I also deleted all the directories in $HOME that may have had some effect on the version, .node, .npm, .yarn, and anything else that seemed somehow related to node.js/npm/yarn.

... same problem.

protoEvangelion commented 5 years ago

What is the output of: which gh and npm root -g?

rotty3000 commented 5 years ago
]$ which gh
/usr/local/bin/gh
]$ npm root -g
/usr/lib/node_modules
rotty3000 commented 5 years ago

with that I discovered I have: /usr/local/lib/node_modules/gh and /usr/lib/node_modules/gh I think I should be able to figure out from here where the two come from by asking apt who provides those directories. I'll put the info here for posterity once I figure that out.

protoEvangelion commented 5 years ago

Hmm I resolved a similar issue by manually setting where npm installs global dependencies with these instructions: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally#manually-change-npms-default-directory

That might resolve your issue as well :)

rotty3000 commented 5 years ago

so I couldn't find the package that provided the /usr/local/ stuff, so I just removed gh from there, and now I get the right version. Thx for you help!