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] Run Scripts and Lifecycle Scripts Broken on IBM i #6025

Closed
2 tasks done
DavidRusso opened this issue Jan 4, 2023 · 5 comments
Closed
2 tasks done

[BUG] Run Scripts and Lifecycle Scripts Broken on IBM i #6025

DavidRusso opened this issue Jan 4, 2023 · 5 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@DavidRusso
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

This issue applies to certain versions of NPM supplied by IBM in the yum repos for the IBM i operating system. This issue does NOT seem to affect the same versions of NPM on other platforms.

Affected NPM versions:

  • NPM 8.9.2 which is included with Node.js 16.18.1 for IBM i.
  • NPM 8.9.2 which is included with Node.js 18.12.1 for IBM i.

Even though the NPM version number is the same, the behavior is different in the 2 scenarios mentioned above.

In affected versions of NPM, lifecycle and run scripts are entirely broken. This prevents many packages from installing properly.

Take for example this simplistic package (create files in a directory named 'test'):

File test/package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "install": "node install.js",
    "do_something": "node do_something.js"
  },
  "author": "",
  "license": "ISC"
}

File test/install.js:

console.log("install.js script ran successfully!");

File test/do_something.js:

console.log("do_something.js script ran successfully!");
  • With the copy of NPM 8.9.2 shipped with Node.js 16.18.1, running npm install from inside the 'test' directory fails with this output:
> test@1.0.0 install
> node install.js

node install.js: --:  not found
npm ERR! code 127
npm ERR! path /home/drusso/test
npm ERR! command failed
npm ERR! command sh -c -- node install.js
  • With the copy of NPM 8.9.2 shipped with Node.js 16.18.1, running npm run do_something from inside the 'test' directory fails with this output:
> test@1.0.0 do_something
> node do_something.js

node do_something.js: --:  not found
  • With the copy of NPM 8.9.2 shipped with Node.js 18.12.1, running the 2 commands mentioned above from within the 'test' directory works properly. However, if you change to the parent directory of 'test' and run npm run --prefix test do_something, it fails with this output:
> test@1.0.0 do_something
> node do_something.js

node do_something.js: --:  not found

These problems suddenly cropped up with the recent updates to the nodejs16 and nodejs18 packages in the IBM i yum repos. For example, NPM 8.5.0 shipped with Node.js 16.14.2 is NOT affected. Also, NPM 8.6.0 shipped with Node.js 18.0.0 is NOT affected.

Expected Behavior

The lifecycle and run scripts should execute without error.

Steps To Reproduce

See above.

Environment

  • npm: 8.9.2
  • Node.js: 16.18.1
  • OS Name: IBM i 7.3, 7.4, and 7.5
  • System Model Name: n/a, multiple models
  • npm config:
; node bin location = /QOpenSys/pkgs/lib/nodejs16/bin/node
; node version = v16.18.1
; npm local prefix = /home/drusso
; npm version = 8.19.2
; cwd = /home/drusso
; HOME = /home/DRUSSO
; Run `npm config ls -l` to show all defaults.
  • npm: 8.9.2
  • Node.js: 18.12.1
  • OS Name: IBM i 7.3, 7.4, and 7.5
  • System Model Name: n/a, multiple models
  • npm config:
; "global" config from /QOpenSys/pkgs/lib/nodejs18/etc/npmrc

script-shell = "/QOpenSys/pkgs/bin/bash"
tarball = "/QOpenSys/pkgs/lib/nodejs18/node-headers.tar.gz"

; node bin location = /QOpenSys/pkgs/lib/nodejs18/bin/node
; node version = v18.12.1
; npm local prefix = /home/drusso
; npm version = 8.19.2
; cwd = /home/drusso
; HOME = /home/DRUSSO
; Run `npm config ls -l` to show all defaults.
@DavidRusso DavidRusso added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jan 4, 2023
@ljharb
Copy link
Collaborator

ljharb commented Jan 4, 2023

npm 8 is EOL, have you tried npm 9 latest?

(Also if the behavior only occurs on a patched version of npm, that seems like something that should be reported to the patch authors)

@DavidRusso
Copy link
Author

DavidRusso commented Jan 4, 2023

I have notified the folks at IBM who manage the Node/NPM repos for IBM i.

On IBM i, it's not common for users to manually install or upgrade NPM and Node. We use packages that are provided by IBM in 'yum' repositories that they manage. I'm not aware of whether the NPM they supply is a patched or a vanilla copy, but I have observed the problem only happens on IBM i.

So, using NPM 9 latest would not be an ideal solution here, as the typical IBM i user is going to have the affected copy of NPM from the IBM repos.

But, I will try it out and report the results...

@kadler
Copy link

kadler commented Jan 4, 2023

This is caused by npm/run-script#103, which affects any platform whose sh doesn't support the -- option to delimit the end of options to sh itself.

We tried to work around this by setting script-shell to bash in the global npm config, but I think #5297 prevented that from being an effective workaround.

Apparently the run-script bug was fixed according to npm/run-script#103 (comment), so I'll see if we can get those changes backported in to our packages.

@DavidRusso
Copy link
Author

DavidRusso commented Jan 4, 2023

@kadler thanks! That would certainly explain it.

Meanwhile, I tried NPM 9 latest and the problem is solved there. That would be great if we could get an updated or patched copy of NPM in the IBM i yum repos.

@DavidRusso
Copy link
Author

This is resolved with kadler's updates to Node.js/NPM in the IBM i repos.

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 Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

3 participants