pnpm: pnpm install -global doesn't create symlink to /usr/local/bin

pnpm version:

2.15.0

Code to reproduce the issue:

waylandchan@bctmac ~/sandbox/orderbook$ which tsc
tsc not found
waylandchan@bctmac ~/sandbox/orderbook$ pnpm install -g typescript
Packages: +1
+
Resolving: total 1, reused 1, downloaded 0, done

/usr/local/Cellar/node/10.9.0/pnpm-global/1:

    typescript 3.0.3

waylandchan@bctmac ~/sandbox/orderbook$ which tsc
tsc not found
waylandchan@bctmac ~/sandbox/orderbook$ pnpm --version
2.15.0
waylandchan@bctmac$ ~/sandbox/orderbook$ node --version
v10.9.0
waylandchan@bctmac$ ~/sandbox/orderbook$ npm bin -g
/usr/local/bin
waylandchan@bctmac$ ~/sandbox/orderbook$ pnpm bin -g
/usr/local/bin
waylandchan@bctmac$ ~/sandbox/orderbook$ ls -al /usr/local/Cellar/node/10.9.0/bin/tsc
-rwxr-xr-x 1 waylandchan staff 2857 Sep 4 18:55 /usr/local/Cellar/node/10.9.0/bin/tsc
waylandchan@bctmac$ ~/sandbox/orderbook$ date
Tue Sep 4 18:56:06 HKT 2018

Expected behavior:

I expect the ‘tsc’ binary to be installed and present on my current path, which it isn’t. My guess is that there should be a symlink from /usr/local/Cellar/node/10.9.0/bin/tsc => /usr/local/bin/tsc

Actual behavior:

The pnpm i -g typescript only gets installed to /usr/local/Cellar/node/10.9.0/bin

Additional information:

This bug was first reported in Issue 695

  • node -v prints: v10.9.0 OSX High Sierra 10.13.5

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 36 (10 by maintainers)

Commits related to this issue

Most upvoted comments

The latest version of pnpm should have fixes for all these issues.

I don’t know if it’s the same issue, but --global isn’t working correctly on Windows either. Packages are being installed to APPDATA even if prefix is set:

> npm bin -g
C:\Users\mrkishi\scoop\persist\nodejs\bin

> pnpm bin -g
C:\Users\mrkishi\scoop\persist\nodejs\bin

> npm config get prefix -g
C:\Users\mrkishi\scoop\persist\nodejs\bin

> pnpm config get prefix -g
C:\Users\mrkishi\scoop\persist\nodejs\bin

> pnpm i -g rimraf
Packages: +12
++++++++++++
Resolving: total 12, reused 0, downloaded 12, done

C:\Users\mrkishi\AppData\Roaming\npm\pnpm-global\1:
+ rimraf 2.6.2

Hey @zkochan Don’t work in 2.15.3 either, I tried same couple of months ago and it was not working even then. So I moved back to npm.

OSX High Sierra 10.13.6

I published a fix. You can install it via: npm i -g pnpm@dev.

Let me know if it solves some of the issues.

Trying to figure out the location of the global npm bins seems to not work well. Setting pnpm-prefix is not very user friendly. Finding the right location for the bins is super hard because there are different OS and toolings.

I think we can try the next solution:

  1. Take the directories from the PATH env variable.
  2. If one of the directories has node, nvm, nvs, npm in the path, take it. If not, write the bin to the first directory to which pnpm has write permission.

I’d just like to report that I haven’t noticed an issue with this since the reported fix, so a thank you!

How do I gain full explicit manual control over where binaries are installed/linked? Instead of fixing corner case after corner case in the complicated logic that tries to figure out the executables location by itself, why not let the user circumvent the issue completely and specify the location imperatively?

The issue here is that I CANNOT FOR THE LIFE OF ME convince pnpm to install binaries somewhere I have write permissions to, and I can’t use sudo because I want to install from a private github repo and root doesn’t have my keys!

Any updates? I really want to switch to pnpm but the global install issue block me. I first meet this issue one year ago, now one year passed but it seems we haven’t make any progress on this.

@ExE-Boss did pnpm-prefix solve the issue in your case?

why not a default pnpm-prefix="$HOME/.pnpm", then:

$HOME
└── .pnpm
    └── bin
    └── pnpm-global
    └── pnpm-store

We can just export PATH="$PATH":"$HOME/.pnpm/bin" … (we can also edit the sys env in pnpm postinstall script)

Also ran into this issue. Coming back to pnpm after briefly trialing it a few years ago when it was fresh and understandably rough around the edges… disappointing to see some aspects still don’t work properly.

Nevermind, I had been using node/npm installed via homebrew (as mentioned by @snowe2010) and there does indeed seem to be some kind of incompatibility.

Maybe this is the real issue here? Either way it needs fixing… Homebrew is by far the best way to install things on macOS.

I’m installing pnpm for the first time and encountering this issue. The recommended install command npx pnpm add -g pnpm fails to symlink pnpm. My Node is installed via homebrew.

Also I had to dig reallly long to find about pnpm-prefix it definitely should be added into the docs, i guess here (?): https://pnpm.js.org/en/configuring

I still can’t use pnpm to install globally either on Win10. I am using node installed via nvm, so directories are wonky, but nvm -g works fine…

still seeing this on 3.4.1.

/ 
➜ yarn global add pnpm
yarn global v1.13.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[#################---------------------------------------------------------------------------------------------------------------------------------------------------------------] 452/462[#[#################################################################################################################--------------------------------------------------------------] 2994/4[###[4/4] 🔨  Building fresh packages...

success Installed "pnpm@3.4.1" with binaries:
      - pnpm
      - pnpx
✨  Done in 4.63s.

/  took 5s
➜ pnpm install -g jira-cl
 WARN  jira-cl > request-promise: request-promise-core@1.1.2 requires a peer of request@^2.34 but none was installed.
 WARN  jira-cl: request-promise@4.2.4 requires a peer of request@^2.34 but none was installed.
Packages: +279
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Resolving: total 279, reused 0, downloaded 279, done
node_modules/.registry.npmjs.org/core-js/2.6.9/node_modules/core-js: Running postinstall script, done in 146ms
node_modules/.registry.npmjs.org/hugo-bin/0.43.6/node_modules/hugo-bin: Running postinstall script, done in 3s

/usr/local/Cellar/node/11.7.0/pnpm-global/2:
+ jira-cl 1.2.1

/  took 25s
➜ jira
zsh: command not found: jira

/ 
➜ which node
/usr/local/bin/node

/ 
➜ node -v
v11.7.0
Edit:

Appears this might be an issue with node being installed via brew (though I was sure I hadn’t installed via brew, because I knew that could cause issues). Once I used this script, pnpm is able to set it globally