compiler icon indicating copy to clipboard operation
compiler copied to clipboard

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

Open thepowercare opened this issue 2 years ago • 8 comments

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

[email protected] watch elm-live src/Main.elm --port=8012 -- --output=dist/index.js

elm-live: Server has been started! Server details below: - Website URL: http://localhost:8012 - Serving files from: /workspaces/elmish-dev-002

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' +

},


  • Elm:
  • 0.19.1
  • Browser:
  • Any
  • Operating System:
  • Windows 10 - WSL2
  • Also running iis on the machine and port 8000 already occupied.

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" } }

thepowercare avatar Jun 05 '23 08:06 thepowercare

Thanks for reporting this! To set expectations:

  • Issues are reviewed in batches, so it can take some time to get a response.
  • Ask questions in a community forum. You will get an answer quicker that way!
  • If you experience something similar, open a new issue. We like duplicates.

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

github-actions[bot] avatar Jun 05 '23 08:06 github-actions[bot]

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

thepowercare avatar Jun 05 '23 09:06 thepowercare

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.

fdbeirao avatar Jun 05 '23 09:06 fdbeirao

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 avatar Jun 05 '23 09:06 thepowercare

Solved by applying @fdbeirao suggestion :)

thepowercare avatar Jun 05 '23 09:06 thepowercare

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 🙂

fdbeirao avatar Jun 05 '23 09:06 fdbeirao

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 avatar Jun 05 '23 11:06 thepowercare

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

thepowercare avatar Jun 05 '23 11:06 thepowercare