microsoft / rushstack

Monorepo for tools developed by the Rush Stack community
https://rushstack.io/
Other
5.9k stars 595 forks source link

[api-extractor] `/usr/bin/env: 'node\r': No such file or directory` when starting version 7.38.1 with `npx` #4413

Closed haakonflatval-cognite closed 11 months ago

haakonflatval-cognite commented 12 months ago

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

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
dmichon-msft commented 12 months ago

This sounds like the bin stub was emitted with CRLF line endings for some reason.

octogonz commented 11 months ago

@dmichon-msft @iclanton it sounds related to this Zulip issue report:

Rob Lisiecki wrote:

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 update

rush 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)

octogonz commented 11 months ago

Proposal for PNPM to catch this problem in the future: https://github.com/pnpm/pnpm/issues/7311