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

Fix Windows-style line endings #185

Closed
michaelbromley opened this issue Oct 17, 2019 · 2 comments
Closed

Fix Windows-style line endings #185

michaelbromley opened this issue Oct 17, 2019 · 2 comments
Assignees
Labels
type: bug 🐛 Something isn't working @vendure/core

Comments

@michaelbromley
Copy link
Member

Describe the bug
(Reported by Nathan via Slack)
Just ran yarn create @vendure my-app and got the following error:

/usr/bin/env: 'node\r': No such file or directory
error Command failed.  

Yarn 1.17.3, node v10.15.2, Ubuntu 18.04.3 LTS
running npx @vendure/create my-app works as expected

Follow-up from David:

Nathan seems like line endings problem:
https://stackoverflow.com/questions/30344858/

I guess that Michael develops Vendure on Windows and I’ve noticed lines in some files in git repository end with \r\n (instead of \n). For example on MacOS:

$ git clone https://github.com/vendure-ecommerce/vendure
$ file vendure/scripts/check-imports.ts
vendure/scripts/check-imports.ts: ASCII text, with CRLF line terminators
$ file vendure/packages/core/src/entity/register-custom-entity-fields.ts
vendure/packages/core/src/entity/register-custom-entity-fields.ts: ASCII text, with CRLF line terminators
@michaelbromley michaelbromley added type: bug 🐛 Something isn't working @vendure/core labels Oct 17, 2019
@michaelbromley michaelbromley self-assigned this Oct 17, 2019
@michaelbromley
Copy link
Member Author

I checked and I already have core.autocrlf set to true. This should in theory solve the issue with letting bad endings into the repo.

However, checking the current HEAD per this SO answer gives:

Michael@XPS15 MINGW64 /c/Development/vendure/vendure (master)
$ git grep -I --files-with-matches --perl-regexp '\r' HEAD
HEAD:packages/core/src/entity/register-custom-entity-fields.ts
HEAD:scripts/check-imports.ts

Not sure how these files made it in there. I'll add a pre-push script to double check this.

yarn issue

There seems to be a separate issue with Yarn specifically (not npm): yarnpkg/yarn#5480

@michaelbromley
Copy link
Member Author

michaelbromley commented Oct 17, 2019

Ok here's what seems to be the issue:

When installing from the npm registry, all the .js and .dts files generated by TypeScript will have LF line endings. This is because it is configured this way in the tsconfig.json file: "newLine": "LF". All good.

However, the @vendure/create/index.js file which is executed when installing via @vendure/create is not transpiled by TypeScript, and thus retains the CRLF line endings from the Windows platform I wrote it on.

Somehow the npm client can deal with this, whereas yarn cannot.

The solution is to use a .gitattributes file to ensure these particular files are always kept with LF newlines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working @vendure/core
Projects
None yet
Development

No branches or pull requests

1 participant