Open SeidChr opened 1 month ago
For everyone who stumples upon this:
there is a workarround (not a real solution):
Using homey app run --remote
to start the app on the homey pro directly, bypassing the docker container.
Its slower, and thats why i wont really consider it a solution. But it enabled me to continue working.
Thx to robertklep from https://community.homey.app/t/app-json-not-found/117317
running in a debian dev container on a windows host.
What do you mean with this are you running docker inside docker?
I'm facing the same issue running on WSL2, so it doesn't seem to be related to/caused by docker inside docker.
I'm facing the same issue running on WSL2, so it doesn't seem to be related to/caused by docker inside docker.
I'm using WSL2 aswell with Ubuntu distro and it works fine. It almost looks like the cli failed to mount the app directory into the homey-app-runner container.
running in a debian dev container on a windows host.
What do you mean with this are you running docker inside docker?
TBH, i am not so sure how the docker-magic is wired up. The container is set up so it communicates with the docker-service on the host machine. So no, not docker inside docker, but 2 containers next to each other. One is running the dev-container, one is running the homey-app, which seems to not have access to the app data
{
"name": "PowerShell",
"image": "mcr.microsoft.com/powershell:lts-debian-11",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "true",
"username": "vscode",
"upgradePackages": "false",
"nonFreePackages": "true"
},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"moby": true,
"installDockerBuildx": true,
"version": "latest",
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"installYarnUsingApt": true,
"version": "lts",
"pnpmVersion": "latest",
"nvmVersion": "latest"
},
"ghcr.io/devcontainers-community/npm-features/prettier:1": {
"version": "latest"
}
},
"postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\" && npm install --global --no-optional homey",
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "pwsh"
},
"extensions": [
"ms-vscode.powershell",
"humao.rest-client",
"donjayamanne.githistory",
"mhutchie.git-graph"
]
}
}
}
running in a debian dev container on a windows host.
What do you mean with this are you running docker inside docker?
TBH, i am not so sure how the docker-magic is wired up. The container is set up so it communicates with the docker-service on the host machine. So no, not docker inside docker, but 2 containers next to each other. One is running the dev-container, one is running the homey-app, which seems to not have access to the app data
{ "name": "PowerShell", "image": "mcr.microsoft.com/powershell:lts-debian-11", "features": { "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": "true", "username": "vscode", "upgradePackages": "false", "nonFreePackages": "true" }, "ghcr.io/devcontainers/features/docker-outside-of-docker:1": { "moby": true, "installDockerBuildx": true, "version": "latest", "dockerDashComposeVersion": "v2" }, "ghcr.io/devcontainers/features/node:1": { "nodeGypDependencies": true, "installYarnUsingApt": true, "version": "lts", "pnpmVersion": "latest", "nvmVersion": "latest" }, "ghcr.io/devcontainers-community/npm-features/prettier:1": { "version": "latest" } }, "postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\" && npm install --global --no-optional homey", "customizations": { "vscode": { "settings": { "terminal.integrated.defaultProfile.linux": "pwsh" }, "extensions": [ "ms-vscode.powershell", "humao.rest-client", "donjayamanne.githistory", "mhutchie.git-graph" ] } } }
https://github.com/athombv/node-homey/blob/4810d75bb2c8204407ca9888bfd6ca0f4edd07f5/lib/App.js#L690
Here is what is passed to the container on start.
I have the same issue. One app runs on Docker container, another app thows this error:
✓ Validating app...
✓ App validated successfully against level `debug`
✓ Creating Remote Debug Session...
✓ Preparing Environment Variables...
✓ Connecting to `Homey Pro 23`...
✓ Starting `de.ronnywinkler.homey.gruenbeck@1.3.2` remotely...
✓ Starting debugger at 0.0.0.0:9229...
— Open `about://inspect` in Google Chrome and select the remote target.
✓ Starting `de.ronnywinkler.homey.gruenbeck@1.3.2` in a Docker container...
— Press CTRL+C to quit.
─────────────── Logging stdout & stderr ───────────────
Debugger listening on ws://0.0.0.0:9229/835d49eb-df7f-45fe-a46f-432db0bb12ca
For help, see: https://nodejs.org/en/docs/inspector
node:internal/modules/cjs/loader:1143
throw err;
^
Error: Cannot find module '/app/app.json'
Require stack:
- /homey-app-runner/lib/App.js
- /homey-app-runner/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at Module.homeyRequire [as require] (/node_modules/@athombv/homey-apps-sdk-v3/index.js:12:19)
at require (node:internal/modules/helpers:177:18)
at new App (/homey-app-runner/lib/App.js:60:21)
at Object.<anonymous> (/homey-app-runner/index.js:15:18)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/homey-app-runner/lib/App.js', '/homey-app-runner/index.js' ]
}
I can't see any difference between both apps. I run the apps in Docker mode to debug the widget via ADB. So running with --remote would not be a good solution.
@jeroenwienk As suggested by Robert (via Slack) it seems this issue is caused by a race condition.
A difference between both apps is:
1) The working one is stored locally (SSD drive) because the amount of files requires a SSD drive to build the app in a short time. It seems the SSD is fast enough to provide the files for Docker upload.
2) The app with Docker issue is stored on a network drive (HDD). This results in a longer build time. Perhaps the HDD/LAN is not fast enought. This app crashes with the error Error: Cannot find module '/app/app.json'
I created a repository copy now on a local SSD drive. Now the app is uploaded to Docker and started correctly. It seems caused by the faster file access the Docker upload is faster than over a network drive. Can the Docker start gets delayed until all files are copied to prevent such issues?
it seems this issue is caused by a race condition.
It looks rather like the homey docker file mapping doesnt support anything other than local disk. As i am running inside of docker and trying to mount the path from one docker to the next, it fails. Your trying to map from a network drive to docker, which also fails.
What works however, is mapping from a local disk
@SeidChr running Docker inside Docker presents a whole bunch of issues regarding bind mounts, see this post, and I'm not surprised that it's not working.
i guess the homey cli just needs to detect its running in an devcontainer. then need to figure out the acutal host-path that needs to be mounted, rather than the docker-local path
so i have just had success with a little experiment. its actually possible to get the host-path for a given container-path from inside a dev-container:
docker inspect $env:HOSTNAME | ConvertFrom-Json |% Mounts |? Destination -eq (get-location) |% Source
Essentially find the container id, make a docker inspect, and find the mount which has the Destination set to the path you are looking for. then take the Source of that mount.
How this gets into the correct place in the homey script however ... 🤷♂️
And with some emotional ChatGPT support:
const fs = require('fs');
const { execSync } = require('child_process');
function GetDockerHostPath(workspaceFolder) {
let result = workspaceFolder;
try {
if (fs.existsSync('/var/run/docker.sock')) {
// Get the container ID from the HOSTNAME environment variable
const containerId = process.env.HOSTNAME;
if (!containerId) {
throw new Error('Container ID not found in HOSTNAME environment variable.');
}
// Get the host path of the mapped folder
const inspectOutput = execSync(`docker inspect ${containerId}`).toString();
const inspectData = JSON.parse(inspectOutput);
if (!inspectData || !inspectData[0] || !inspectData[0].Mounts) {
throw new Error('Invalid Docker inspect data.');
}
const mounts = inspectData[0].Mounts;
const mount = mounts.find(mount => mount.Destination === workspaceFolder);
if (!mount) {
throw new Error(`No mount found for destination: ${workspaceFolder}`);
}
result = mount.Source;
}
} catch (error) {
console.Log('Unable to determine docker host-path. Using local workspace folder.', error);
}
return result;
}
Completely blank app. Nothing changed after homey app create. Anything i can do?
running in a debian dev container on a windows host. homey pro is standing next to me. connected to the same network.