elm-live dies hard when it cant find output files.
thepowercare opened this issue · 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
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:
- 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"
}
}
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.
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
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.
Solved by applying @fdbeirao suggestion :)
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 🙂
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.
The solution: "watch": "elm-live src/Main.elm --dir=dist --port=8011 -- --debug --output=dist/index.js",