branchseer / DeskGap

A cross-platform desktop app framework based on Node.js and the system webview
https://deskgap.com/
MIT License
1.83k stars 75 forks source link

Can't run deskgap on Linux because of line endings #33

Closed matt-allan closed 4 years ago

matt-allan commented 5 years ago

Hello,

I was following the guide in the README on Ubuntu Linux 19.04. When I tried to run yarn start I encountered the following error:

$ yarn start
yarn run v1.16.0
warning package.json: No license field
$ deskgap .
/usr/bin/env: ‘node\r’: No such file or directory
error Command failed with exit code 127.

If I execute /usr/bin/env node directly it works as expected:

$ /usr/bin/env node
Welcome to Node.js v12.4.0.
Type ".help" for more information.
> 

Eventually I was able to resolve the issue by running dos2unix on the cli.js file:

$ dos2unix ./node_modules/deskgap/cli.js
dos2unix: converting file ./node_modules/deskgap/cli.js to Unix format...

The file command shows that cli.js (and it looks like the rest of the files too) has CRLF line terminators:

$ file ./node_modules/deskgap/cli.js    
./node_modules/deskgap/cli.js: a /usr/bin/env node script, ASCII text executable, with CRLF line terminators
rezaxdi commented 5 years ago

I can confirm this problem with ubuntu 18.04 and node v8.10

matt-allan commented 5 years ago

I've been reading up on this and it sounds like if you check the project out with git the line endings should be fixed automatically.

The problem seems to happen when you check the project out on a windows computer, then publish to NPM, as explained in this NPM issue.

I think we might be able to set npm/cli.js text eol=lf in a .gitattributes file to prevent this from happening? It would ensure that the line endings are always converted to LF on checkout, even on Windows. We would then need to publish a new package. I don't have a Windows machine to test this on and confirm it doesn't break anything though.

remorses commented 4 years ago

Same on Mac os with version 0.1.0