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

Error when running from a yarn script #6

Closed
maxfi opened this issue Aug 5, 2020 · 15 comments
Closed

Error when running from a yarn script #6

maxfi opened this issue Aug 5, 2020 · 15 comments

Comments

@maxfi
Copy link
Contributor

maxfi commented Aug 5, 2020

With the following yarn script:

{
  "scripts": {
    "fauna-gql-upload": "fauna-gql"
  },
}

when running yarn run fauna-gql-upload the following error is produced:

/usr/bin/env: ‘node\r’: No such file or directory
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is an issue with yarn.

Converting https://github.com/Plazide/fauna-gql-upload/blob/master/index.js#L1 to use Unix line endings (LF rather than CRLF) fixes the issue.

I can create a pull request if you agree. Thanks.

@Plazide
Copy link
Owner

Plazide commented Aug 8, 2020

Sure, create a pull request.

Probably best to just use LF for all files.

Never encountered this before, so good catch!

@maxfi
Copy link
Contributor Author

maxfi commented Aug 8, 2020

So this is kinda weird...

When I yarn install the package I get the following:

node_modules/fauna-gql-upload$ file index.js 
index.js: a /usr/bin/env node script, ASCII text executable, with CRLF line terminators

But when I clone this repo I get:

fauna-gql-upload$ file index.js 
index.js: a /usr/bin/env node script, ASCII text executable

Any ideas? Is there something happening when you publish the package?

@Plazide
Copy link
Owner

Plazide commented Aug 8, 2020

Yeah, that is strange.

I did the same check as you did above, but got the opposite results.

In the project folder I get:
bild

But when the package is installed I get:
bild

Don't really know what to make of this. I don't do anything special when publishing to npm, just npm publish. I thought maybe it's the tarball created by npm that changes the line endings, but then the line endings should be the same after installing.

Could possibly be another issue with yarn. Which version are you using? I'm using 1.19.1.

@maxfi
Copy link
Contributor Author

maxfi commented Aug 12, 2020

Sorry about the late reply. Yeah, that's really strange...

Do you get the error:

/usr/bin/env: ‘node\r’: No such file or directory
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

when running from a yarn script?

I'm using yarn 1.22.4. Vercel also uses the same version and I'm getting the same error on deployments there.

@Plazide
Copy link
Owner

Plazide commented Aug 12, 2020

I don't get that error, but I'll try and update yarn to your version and see if it happens.

@Plazide
Copy link
Owner

Plazide commented Aug 12, 2020

So, I updated yarn. Still not getting an error. Though I noticed that when installing with version 1.22.4, the installed package file returns

node_modules/fauna-gql-upload/index.js: a /usr/bin/env node script, ASCII text executable, with CRLF line terminators

The same as yours. So, that seems to be a difference across yarn versions.

I can't seem to reproduce the error, either on windows or ubuntu. I'm using WSL, so I even tried yarn install on windows and then running yarn run fauna-gql-upload on the Ubuntu distro. Still no error.

Could you share a repo to reproduce the error? Even though changing the line endings solves it, I'd still like to know what the cause is.

@maxfi
Copy link
Contributor Author

maxfi commented Aug 12, 2020

Very strange...

I've found this issue: yarnpkg/yarn#5480
and from there a link to here: sainthkh/reasonql#14 (comment)

I'll investigate I bit further tomorrow and try to create a minimal reproduction. Will keep you posted. Thanks.

@maxfi
Copy link
Contributor Author

maxfi commented Aug 15, 2020

@Plazide I can't figure this out... What do you think about adding the .gitattributes file that sets the line endings and then publishing a patch version to test if it worked?

@Plazide
Copy link
Owner

Plazide commented Aug 15, 2020

Sure, let's try that. Create the PR, I'll merge, and then publish a dev version on npm.

@Plazide
Copy link
Owner

Plazide commented Aug 21, 2020

@maxfi I added the .gitattributes file and published a new version to npm with a dev tag. Try yarn add [email protected] and tell me if it works for you.

@maxfi
Copy link
Contributor Author

maxfi commented Aug 23, 2020

Thanks for that @Plazide. 🙏 Unfortunately it didn't work though. 🤔

@maxfi
Copy link
Contributor Author

maxfi commented Aug 24, 2020

@Plazide any ideas how I can troubleshoot this? Thanks.

@Plazide
Copy link
Owner

Plazide commented Aug 24, 2020

@maxfi I really have no idea.

Do you have the same problem with every version of the package? Or is it just the later versions?

@Plazide
Copy link
Owner

Plazide commented Aug 25, 2020

@maxfi I published another version yesterday, [email protected]. Try installing that, but maybe delete your node_modules before you do that.

I changed some local git settings, specifically core.autocrlf. It was set to true which means git converts all line-endings to CRLF. I've changed this setting to input, which is the recommended setting on Unix based systems.

Hopefully, it will help.

@maxfi
Copy link
Contributor Author

maxfi commented Aug 26, 2020

@Plazide Woohooo! It's working now with the latest version! 🥳 Thanks so much for getting it sorted! 🙏

@maxfi maxfi closed this as completed Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants