Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): support custom global bin dir #3762

Merged
merged 16 commits into from
Sep 11, 2021
Merged

Conversation

umireon
Copy link
Member

@umireon umireon commented Sep 10, 2021

Abstract

It would be great that the package manager can customize the global bin directory along with its policy.
I propose global-bin-dir in a npmrc to customize the global bin directory of pnpm.

Use case

Homebrew/homebrew-core#82892
In Homebrew, create /usr/local/etc/npmrc and add global-bin-dir = ${HOME}/Library/pnpm to it.
It will change the global bin directory to ~/Library/pnpm without PNPM_HOME set.

(In Linuxbrew, ~/.local/pnpm would be used)

References

#3713

Read /usr/local/etc/pnpmrc to support the platform-specific global bin dir.
@umireon
Copy link
Member Author

umireon commented Sep 10, 2021

This change is for Homebrew/homebrew-core@4546e4c.

@zkochan
Copy link
Member

zkochan commented Sep 10, 2021

pnpm uses npm's config system and we already read the global npmrc file. Can't we just reuse that?

Read /usr/local/etc/npmrc
@umireon umireon changed the title feat(config): support builtin pnpmrc feat(config): support custom global bin dir Sep 11, 2021
@umireon
Copy link
Member Author

umireon commented Sep 11, 2021

@zkochan I removed pnpmrc and this PR is just adding the pnpm-bin option to specify the pnpm's global bin dir.
I left the behavior unchanged without the pnpm-bin option.

@umireon
Copy link
Member Author

umireon commented Sep 11, 2021

pkg -t macos-node14-arm64 must fail on Intel Mac so that we need to fix build-artifacts.ts in another PR.

@zkochan
Copy link
Member

zkochan commented Sep 11, 2021

some tests should be added.

@umireon
Copy link
Member Author

umireon commented Sep 11, 2021

I'm struggling to create tests😅

Copy link
Member

@zkochan zkochan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changeset for your change

Run pnpm changeset

@umireon
Copy link
Member Author

umireon commented Sep 11, 2021

@zkochan

Please add a changeset for your change

Yes, tomorrow. I have to wait for CI.

@umireon
Copy link
Member Author

umireon commented Sep 11, 2021

slash and backslash problem.

@umireon
Copy link
Member Author

umireon commented Sep 11, 2021

Investigating

This reverts commit 4feafac.
@umireon
Copy link
Member Author

umireon commented Sep 11, 2021

os.tmpdir() returns /var/folders/d5/*/T but /var is symlinked to /private/var so that the realpath is /private/var/folders/d5/*/T and it causes the error only in macOS.

@zkochan zkochan added this to the v6.15 milestone Sep 11, 2021
@zkochan zkochan merged commit 6681fdc into pnpm:main Sep 11, 2021
@umireon
Copy link
Member Author

umireon commented Sep 12, 2021

Oh thanks for the changeset. I couldn't wait for CI and fell asleep.

umireon added a commit to umireon/homebrew-core that referenced this pull request Sep 25, 2021
With this config, pnpm will install global package's executables into ~/Library/pnpm (macOS) or ~/.local/pnpm (Linux) by default.
This config allows pnpm to provide the command `pnpm env use --global 16` safely with Homebrew.
Refer to pnpm/pnpm#3762.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants