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] Npm script-shell Setting Not Respected by rush #5076

Open
stan-kondrat opened this issue Jan 11, 2025 · 2 comments
Open

[rush] Npm script-shell Setting Not Respected by rush #5076

stan-kondrat opened this issue Jan 11, 2025 · 2 comments
Labels
effort: medium Needs a somewhat experienced developer help wanted If you're looking to contribute, this issue is a good place to start!

Comments

@stan-kondrat
Copy link

Summary

Configuring Rush to use Bash as the script shell on Windows via the .npmrc setting (script-shell=bash) does not work with rush. Despite this configuration, rush always defaults to using cmd.exe, whereas npm run correctly respects the script-shell setting.

Reproduction Steps

  1. On Windows, install Git Bash or ensure Bash is available.
  2. Add script-shell=bash to the .npmrc file in the project root.
  3. Create a script in package.json:
    "scripts": {
      "test-script": "echo $0"
    }
  4. Run the script using rushx:
    rushx test-script
  5. Run the same script using npm run:
    npm run test-script

Expected Result

Both rushx test-script and npm run test-script should execute using Bash and output bash.

Actual Result

  • npm run test-script correctly uses Bash and outputs bash.
  • rushx test-script uses cmd.exe and outputs $0, ignoring the script-shell setting.

Technical Details

It appears that rushx does not respect the script-shell configuration in .npmrc, always defaulting to the system shell (cmd.exe on Windows). This inconsistency with npm run may cause issues for projects relying on Unix-like shell behavior.

Suggested Solution

Ensure that rushx checks and honors the script-shell setting from .npmrc when executing scripts, aligning its behavior with npm run.

Standard Questions

Question Answer
@microsoft/rush globally installed version? Yes
rushVersion from rush.json? 5.141.2
useWorkspaces from rush.json?
Operating system? Windows 10/11
Would you consider contributing a PR? No
Node.js version (node -v)? v20.11.0
@iclanton
Copy link
Member

Yup, Rush doesn't look at this setting. By design, Rush only looks at the common/config/rush/.npmrc file, so setting this in an individual project root wouldn't work in general. Adding support for this setting is probably not particularly difficult.

@iclanton iclanton moved this from Needs triage to Low priority in Bug Triage Jan 13, 2025
@iclanton iclanton added help wanted If you're looking to contribute, this issue is a good place to start! effort: medium Needs a somewhat experienced developer labels Jan 13, 2025
@stan-kondrat
Copy link
Author

Rush only looks at the common/config/rush/.npmrc file, so setting this in an individual project root wouldn't work in general.

You are right! I used this file, but I just didn't specify the full path to it explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: medium Needs a somewhat experienced developer help wanted If you're looking to contribute, this issue is a good place to start!
Projects
Status: Low priority
Development

No branches or pull requests

2 participants