[api-extractor] `/usr/bin/env: 'node\r': No such file or directory` when starting version 7.38.1 with `npx`
haakonflatval-cognite opened this issue · 3 comments
Summary
Running any command with api-extractor
through npx
, e.g. npx api-extractor run
crashes with the error
/usr/bin/env: ‘node\r’: No such file or directory
I am only seeing this error on version 7.38.1 of Api-Extractor, not 7.38.0. It is also only occuring on Linux, the command works fine in Windows.
Repro steps
-
On Linux, create a minimal repository with
api-extractor
setup, the package having version 7.38.1 -
Run e.g.
npx api-extractor run
Expected result:
-
Api-Extractor runs with the associated settings
Actual result:
-
Api-Extractor crashes with the above error message.
Details
Standard questions
Please answer these questions to help us investigate your issue more quickly:
Question | Answer |
---|---|
@microsoft/api-extractor version? |
7.38.1 |
Operating system? | Linux |
API Extractor scenario? | reporting |
Would you consider contributing a PR? | Probably not |
TypeScript compiler version? | 5.2.2 |
Node.js version (node -v )? |
18.17.0 |
This sounds like the bin stub was emitted with CRLF line endings for some reason.
@dmichon-msft @iclanton it sounds related to this Zulip issue report:
The latest build of rush has a significant bug for systems that are sensitive to line endings. It is no longer compatible with Linux systems (5.110.0) released October 30 2023. The core files (possibly index.js or other) contain carriage return characters which are incompatible with Linux systems. I would like to open a bug report for this issue but it was suggested that I post here first. Most likely a file was modified by a windows system and the return character was added.
To repro, just install rush on a Linux (perhaps Debian for example) and run Rush install, You will get the following error:
yarn global add @microsoft/rush@5.110.0
echo rush update
rush updaterush update
/usr/bin/env: ‘node\r’: No such file or directory
Failed to run 'override-build': Exit code was 127.The error ‘node\r’: No such file or directory means that the system is attempting to run a command with /r appended, which is being added to the command, the command node, should run, but not ‘node\r’. This likely will only impact systems that do not expect the /r character.
Is this a known issue in the most recent release? I wouldn't mind opening an issue or locating the specific line of code and issuing a PR if this issue is not currently tracked.
Also with the release process, is there a tag or PR for the 5.110.0 I can use to review changes to find the specific file and location of the line ending addition that is causing the issue? This has blocked our pipeline build process for production with a time sensitive deployment. For the time being I have pinned to a previous known working version (5.87.0)
Proposal for PNPM to catch this problem in the future: pnpm/pnpm#7311