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

Tool does not work on Mac OS #1

Closed
dusanradovanovic opened this issue Jan 4, 2019 · 5 comments
Closed

Tool does not work on Mac OS #1

dusanradovanovic opened this issue Jan 4, 2019 · 5 comments

Comments

@dusanradovanovic
Copy link

Hello, and first of all thanks for this awesome tool!

Tool does not work on mac since file src/index.js is using Windows file endings (\r\n). Since this file is being run as a bash script the first line #! /usr/bin/env node fails with an error env: node\r: No such file or directory.

It's always safest to keep Unix line endings (simple \n) when working on node.js projects. In VS Code there is a command Change End Of Line Sequence for single files or you can set Files: EOL option in settings to \n. Changing EOL for src/index.js fixes the issue.

@ceszare
Copy link
Owner

ceszare commented Jan 6, 2019

Hi!

Thank you for the input! I have an outstanding PR where I corrected the line endings on my source files. I have pubished a patch under react-intl-universal-pseudo-converter@lfpatch in case you want to try it out, and if you are successful in runing the tool I can push an update to master.

I did, however, install and run the 1.0.0 version on a Mac Mini and didn't have problems running the tool. Did you try running it in Bash, or were you using another shell?

Thank you so much for the input!

@dusanradovanovic
Copy link
Author

Hi Cesar, thanks for the quick response!

I did some research and here is what I found: Problematic file src/index.js has 1006 bytes when converted to to use just LF endings, however since it has 39 line endings when you convert it to CRLF endings it will be 1045 bytes in size. Now when I install the package in an empty folder with npm install react-intl-universal-pseudo-converter I get a file with 1006 bytes and the tool works as expected. However, when I do the same thing with yarn using yarn add react-intl-universal-pseudo-converter the file has 1045 bytes and the tool gives mentioned error: env: node\r: No such file or directory.

I've thought that this might be yarn's problem so I've downloaded the raw package from the: https://registry.npmjs.org/react-intl-universal-pseudo-converter/-/react-intl-universal-pseudo-converter-1.0.0.tgz and when I peeked into the package I see that src/index.js has 1045 bytes in there. This suggests that npm is doing the auto conversion during install while yarn is leaving things as they are.

What's even more interesting is that when I run git clone (my git is configured to leave line endings as they are) the file on disk is 1006 bytes - same as what GitHub page is showing.

So to summarize:
git repo - 1006 bytes
npm raw tgz - 1045 bytes
after npm install - 1006 bytes
after yarn add - 1045 bytes

This looks like you've published a CRLF version by mistake, or there was maybe some sort of automatic conversion of LF -> CRLF during publish like explained in this issue: npm/npm#2097. So perhaps all you need to do is to re-publish from Mac or re-publish using yarn.

I've cloned the repo and inspected the file in the lf-patch branch, and as far as I can tell apart from adding one new line at the end and changing quotes, no line endings have been changed. Which is fine because they are already set to LF on the master :)

When inspecting the src/index.js file from https://registry.npmjs.org/react-intl-universal-pseudo-converter/-/react-intl-universal-pseudo-converter-1.0.1-lfpatch.tgz the file size suggests LF endings there so you need to re-publish master version the same way you published lf-patch version and everything should be fine then.

@ceszare
Copy link
Owner

ceszare commented Jan 6, 2019

Interesting! Now that I think about it, I think I may have published the original 1.0.0 version from a Windows machine, so the behavior described above makes sense. I will merge the changes back to master, and publish a version 1.0.1 to correct the problem.

I am wondering if creating a .gitattributes file with the proper specification would allow for publishing on Windows to avoid introducing the CR characters... still this is good information. For now I will make sure to only publish on POSIX environments to ensure compatibility.

Thanks!!

@ceszare
Copy link
Owner

ceszare commented Jan 6, 2019

I have added version 1.0.1 to the NPM registry. I will keep the issue open in case you encounter a problem with Yarn.

@dusanradovanovic
Copy link
Author

I've tested 1.0.1 and it works well with both yarn and npm so I'll go ahead and close the issue.

Thanks!

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