Skip to content

[rush] All node_modules/.bin point to the common .bin which precludes different packages with different bin versions #915

Description

@giltayar

If I have package a with mocha v4, and package b with mocha v5, then both package a and b will have a node_modules/.bin, but they both symlink to common/temp/node_modules/.bin, so the command mocha in an npm script will either point to mocha v4 or mocha v5.

I'm not sure why each package has to symlink to the common node_modules/.bin (or why there even needs to be such a common bin). It seems that it is not consistent.

It seems that each package should have a local node_modules/.bin, just as it does in regular npm installs.

(BTW, this happens when package manager is yarn or npm. I couldn't get pnpm working with my stuff)

Activity

  1. changed the title [-]All `node_modules/.bin` point to the common .bin which precludes different packages with different bin versions[/-] [+][rush] All `node_modules/.bin` point to the common .bin which precludes different packages with different bin versions[/+] on Oct 30, 2018
  2. octogonz commented on Oct 30, 2018

    @octogonz
    Collaborator

    Which package manager are you using? For PNPM it seems like we link to the local .bin folder:

    PnpmLinkManager.ts

        // Also symlink the ".bin" folder
        const projectFolder: string = path.join(localPackage.folderPath, 'node_modules');
        const projectBinFolder: string = path.join(localPackage.folderPath, 'node_modules', '.bin');
    
        // Return type is Promise<void[]> because the API returns Promise.all()
        return pnpmLinkBins(projectFolder, projectBinFolder)
          .then(() => { /* empty block */ });
  3. giltayar commented on Oct 30, 2018

    @giltayar
    Author
  4. added
    bugSomething isn't working as intended
    help wantedIf you're looking to contribute, this issue is a good place to start!
    effort: easyProbably a quick fix. Want to contribute? :-)
    on Oct 31, 2018
  5. octogonz commented on Oct 31, 2018

    @octogonz
    Collaborator

    npm or yarn exhibit this behavior.

    I see. We should definitely fix their code paths to look like PnpmLinkManager.ts. NPM and Yarn both use the same file NpmLinkManager.ts, so this should be a pretty easy fix.

  6. chrisdothtml commented on May 3, 2019

    @chrisdothtml

    PR made for this: #1256

  7. trusktr commented on Feb 9, 2020

    @trusktr

    Does this also cover the issue where if a rush-managed project inside the monorepo has a bin command then it does not get linked into other projects that depend on it?

    EDIT: Found it, this is the issue that talks about that specifically, in which Christian Gonzalez (@christiango) mentiones the same pull request: #1100

    Christian Gonzalez (@christiango) Any plans for that pull request?

    At the moment, I have a script that I run after rush update:

    # fix-stuff.sh
    
    # make sure the builder binary is linked. Rush does not link binaries of
    # projects currently. See https://github.com/microsoft/rushstack/issues/915
    ln -sf ../../../../packages/FormidableLabs+builder/bin/builder.js common/temp/node_modules/.bin/builder
    
    ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as intendedeffort: easyProbably a quick fix. Want to contribute? :-)help wantedIf you're looking to contribute, this issue is a good place to start!

    Type

    No type

    Projects

    • Status
      High priority

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions