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

[rush] bin field is ignored for linked packages #1100

Open
lhorie opened this issue Feb 13, 2019 · 10 comments
Open

[rush] bin field is ignored for linked packages #1100

lhorie opened this issue Feb 13, 2019 · 10 comments
Labels
needs more info We can't proceed because we need a better repro or an answer to a question

Comments

@lhorie
Copy link

lhorie commented Feb 13, 2019

If a rush workspace contains two projects, one of which has a bin script and the other depends on the first, the second project will not get a node_modules/.bin symlink to the script of the first.

See this repo for repro steps: https://github.com/lhorie/rush-bin-bug

PS: I'm willing to submit a PR to fix this if someone can guide me to the appropriate whereabouts

@octogonz
Copy link
Collaborator

Your repro is using the style where NPM itself generates the binary script during installation. Since Rush links (rather than installs) the local projects, rush would need to reproduce that binary-generating heuristic, which is nontrivial and a little different for yarn/pnpm/npm.

For our projects, we instead explicitly define the binary script, like this:

https://github.com/Microsoft/web-build-tools/blob/master/apps/api-extractor/bin/api-extractor

The api-documenter project depends on api-extractor. If you run rush install in the web-build-tools repo, you will see that a binary gets written here:

./apps/api-documenter/node_modules/.bin/api-extractor

Would that solve your problem?

@octogonz octogonz added the needs more info We can't proceed because we need a better repro or an answer to a question label Feb 13, 2019
@lhorie
Copy link
Author

lhorie commented Feb 13, 2019

Sorry, I'm not sure I'm following. What's different between the repro repo and the way api-extractor gets written into the node_modules/.bin of api-documenter in the web-build-tools repo?

@Toxaris
Copy link

Toxaris commented Apr 8, 2019

We are having the same issue. Based on the discussion in #915 and #1024, we are guessing that node_modules/.bin symlinks to projects in the same repository only work for using rush with pnpm but not for using rush with yarn.

@octogonz
Copy link
Collaborator

octogonz commented Apr 8, 2019

@lhorie sorry I overlooked your reply back in Feb.

The difference is that with api-extractor's, the symlink target exists at the time when rush install is running, because the target is a source file tracked by Git. Whereas with the other approach, rush install would need to create a symlink to a potentially nonexistent target (i.e. that won't exist until after rush build completes). This can be problematic, e.g. if I remember right, we create hardlinks on Windows, which require the target to exist.

Does that make sense?

@octogonz
Copy link
Collaborator

octogonz commented Apr 8, 2019

@Toxaris I agree that perhaps all these issues could be solved by updating Yarn/NPM to use the more sophisticated pnpmLinkBins() function mentioned in #915 (comment) . Even though it's part of the PNPM package manager library, if I understand right this function should work fine for Yarn and NPM.

This should be an easy fix. Maybe someone could create a PR?

@chrisdothtml
Copy link

Bit late to the party, but after testing with @lhorie 's repro repo, @octogonz 's recommended solution isn't actually why it's working for api-extractor. It still doesn't work after converting the my-cli to an explicit binary. The only reason api-extractor is working is because it's using pnpm instead of yarn.

Looks like the same issue exists with npm, so I think the only solution is something like pnpmLinkBins for npm and yarn

@chrisdothtml
Copy link

PR made for this: #1256

@bweggersen
Copy link
Member

We just hit this issue when trying to add Rush to our repo using yarn as the package manager. Specifically, we can't see any bin scripts added to node_modules/.bin from any of the internal dependencies. Here's a repro repo: https://github.com/bweggersen/rush-bin-bug-yarn

@yeegor
Copy link

yeegor commented Mar 10, 2021

Still experiencing issues with this. Please fix! 😁

@github-project-automation github-project-automation bot moved this to Needs triage in Bug Triage Feb 26, 2024
@mshimokura
Copy link

mshimokura commented May 27, 2024

We are also still experiencing this issue. A workaround is to rush install --only <package with bin> and rush build --only <package with bin> the binary first, then it will be linked into <package requires bin>/node_modules/.bin when you run rush install / rush build later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info We can't proceed because we need a better repro or an answer to a question
Projects
Status: Needs triage
Development

Successfully merging a pull request may close this issue.

7 participants