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

[BUG] <prepare script called with CMD on windows> #7723

Open
2 tasks done
GMartigny opened this issue Aug 14, 2024 · 3 comments
Open
2 tasks done

[BUG] <prepare script called with CMD on windows> #7723

GMartigny opened this issue Aug 14, 2024 · 3 comments
Assignees
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@GMartigny
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Hi,

I'm trying to have a script running on installation of a package and also on clone of the repo (setting up git hooks). So, I wrote a simple shell script:

#!/bin/bash

git config set core.hookspath $path

And use it in prepare and install script on package.json.

{
  "script": {
    "install": ".hooks/setup",
    "prepare": ".hooks/setup"
  }
}

As I'm on windows, I've already defined my shell and script-shell o point to C:\\Program Files\\git\\bin\\bash.exe.

Therefore, is I run .hooks/setup, npm run prepare or npm install the script is correctly executed. But, if I do npm pack or npm publish, I get an error .hooks is not a valid command on the line C:\WINDOWS\system32\cmd.exe /d /s /c .hooks/setup.

Expected Behavior

The shell config should be honored, whatever the way it is used.

Steps To Reproduce

  1. On windows
  2. run npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
  3. Have "prepare": "./test" on package.json's script
  4. Have a simple test executable file with echo "ok" for example
  5. Run npm run prepare => ✅ will print "ok"
  6. Run npm pack => ❌ will throw an error

Environment

  • npm: 10.8.2
  • Node.js: 22.6.0
  • OS Name: Windows 10
  • npm config:
script-shell = "C:\\Program Files\\git\\bin\\bash.exe"
shell = "C:\\Program Files\\git\\bin\\bash.exe"
@GMartigny GMartigny added Bug thing that needs fixing Needs Triage needs review for next steps labels Aug 14, 2024
@GMartigny
Copy link
Author

Might be related to #6435 or #3972

@milaninfy milaninfy added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Sep 16, 2024
@milaninfy
Copy link
Contributor

This is reproducible on windows as described in issue report.

@milaninfy milaninfy self-assigned this Sep 18, 2024
@milaninfy milaninfy added Needs Triage needs review for next steps and removed Priority 2 secondary priority issue labels Sep 20, 2024
@milaninfy
Copy link
Contributor

milaninfy commented Sep 20, 2024

This behaviour seems expected as prepare script run for git dependencies as well as directory for which it's doing pack. scriptshell flag seems to be left out of prepare script intentionally. Need to check some specifics around the issue and code here before it's marked Triaged again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants