elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.48k stars 658 forks source link

elm-live dies hard when it cant find output files. #2305

Open thepowercare opened 1 year ago

thepowercare commented 1 year ago

Quick Summary: When using the community elm container. I'm getting a crash when opening localhost:8012

SSCCE

node ➜ /workspaces/elmish-dev-002 $ npm run watch

elmish-dev-001@1.0.0 watch elm-live src/Main.elm --port=8012 -- --output=dist/index.js

elm-live: Server has been started! Server details below:

Error parsing result: SyntaxError: Unexpected number in JSON at position 2 at JSON.parse () at ChildProcess. (/workspaces/elmish-dev-002/node_modules/elm-live/lib/src/build.js:110:33) at ChildProcess.emit (node:events:513:28) at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12) { build: { action: 'error', data: '\n' + '-- ERROR -----------------------------------------------------------------------\n' + '\n' + 'I ran into something that bypassed the normal error reporting process! I\n' + 'extracted whatever information I could from the internal error:\n' + '\n' + '> dist/index.js: openBinaryFile: permission denied (Permission denied)\n' + '\n' + 'These errors are usually pretty confusing, so start by asking around on one of\n' + 'forums listed at https://elm-lang.org/community to see if anyone can get you\n' + 'unstuck quickly.\n' + '\n' +

},

Additional Details

package.json { "name": "elmish-dev-002", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "watch": "elm-live src/Main.elm --port=8012 -- --debug --output=dist/index.js", "compile": "elm make src/Main.elm --output=dist/index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "Theodor", "license": "ISC", "devDependencies": { "elm-live": "^4.0.2" }, "dependencies": { "elm-format": "^0.8.7" } }

github-actions[bot] commented 1 year ago

Thanks for reporting this! To set expectations:

Finally, please be patient with the core team. They are trying their best with limited resources.

thepowercare commented 1 year ago

Just ran this example, (Attached) which is a lean version of my startup. To my surprise it actually works! So apparently somethin is up with running the initial version. elmish-dev-002.zip

fdbeirao commented 1 year ago

Hello @thepowercare

I am also running Windows 10 with WSL 2. I encounter similar issues with permissions some times.

For me, what I ended up doing was adding this to my devcontainer.json:

"postStartCommand": "rootDir=$PWD; cd .. && user=$(whoami); sudo chown $user -Rf $rootDir && mygroup=$(id -gn); sudo chgrp $mygroup -Rf $rootDir && cd $rootDir"

I think the issue also happens depending if you did the git checkout into WSL, or if you are from WSL connecting to a windows path.

For me I ended up doing the git clone inside WSL, to work around the permissions.

Then, in order to keep using my favorite windows Git client (Fork), I opened the repo at \\wsl.localhost\Ubuntu-22.04\home\...

All in all, I don't think this issue is necessarily related to Elm or even to the community dev container, but more likely to how Windows and WSL interact in terms of file permissions.

thepowercare commented 1 year ago

Hi Fabio

Thank's for the quick response 😄

I had a suspicion that something like this was the root course. But after deleting everything unsessesary for submitting the project to test, I ran the project again, as for the first time. This time the project worked. Smells like the inintial install just had "problems" setting the necessary permissions?!?

Should I close the issue?

Med venlig hilsen

Theodor Heiselberg

Systemudvikler

Adresse

Hjemmeside

Sønderhøj 16, DK-8260 Viby J

powercare.dkhttp://www.powercare.dk/


From: Fábio Beirão @.> Sent: Monday, June 5, 2023 11:10 AM To: elm/compiler @.> Cc: Theodor Heiselberg @.>; Mention @.> Subject: Re: [elm/compiler] Using elm-live from within devcontainer craches (Issue #2305)

Hello @thepowercarehttps://github.com/thepowercare

I am also running Windows 10 with WSL 2. I encounter similar issues with permissions some times.

For me, what I ended up doing was adding this to my devcontainer.json:

"postStartCommand": "rootDir=$PWD; cd .. && user=$(whoami); sudo chown $user -Rf $rootDir && mygroup=$(id -gn); sudo chgrp $mygroup -Rf $rootDir && cd $rootDir"

I think the issue also happens depending if you did the git checkout into WSL, or if you are from WSL connecting to a windows path.

For me I ended up doing the git clone inside WSL, to work around the permissions.

Then, in order to keep using my favorite windows Git client (Fork), I opened the repo at \wsl.localhost\Ubuntu-22.04\home...

All in all, I don't think this issue is necessarily related to Elm or even to the community dev container, but more likely to how Windows and WSL interact in terms of file permissions.

— Reply to this email directly, view it on GitHubhttps://github.com/elm/compiler/issues/2305#issuecomment-1576421957, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6GQL7IMFAHCSLBXDWPIZJLXJWO6TANCNFSM6AAAAAAY2U5IYI. You are receiving this because you were mentioned.Message ID: @.***>

thepowercare commented 1 year ago

Solved by applying @fdbeirao suggestion :)

fdbeirao commented 1 year ago

If you no longer have the issue, then indeed closing would be the way to go. Indeed, permission issues will usually be associated to how you performed the initial git clone. Glad the problem is solved, have a great day further 🙂

thepowercare commented 1 year ago

Solution was short lived :( Tried using elm-go. This hinted that both lib's are looking in the root folder. Moving files from my target folder to root solves this problem.

thepowercare commented 1 year ago
The solution: "watch": "elm-live src/Main.elm --dir=dist --port=8011 -- --debug --output=dist/index.js",