`swa [login|deploy]` fails with `Cannot spawn a message bus without a machine-id` in devcontainer
FelixZY opened this issue · 3 comments
Describe the bug
SWA CLI commands fail with Cannot spawn a message bus without a machine-id
when executing in a debian (mcr.microsoft.com/devcontainers/base:bullseye
) devcontainer.
$ npx swa login
Welcome to Azure Static Web Apps CLI (1.1.7)
Checking Azure session...
✖ Failed to setup project: Cannot spawn a message bus without a machine-id: Unable to load /var/lib/dbus/machine-id or /etc/machine-id: Failed to open file “/var/lib/dbus/machine-id”: No such file or directory
✖ If you believe this behavior is unexpected, please raise a GitHub issue at:
https://github.com/Azure/static-web-apps-cli/issues/new/choose
$ npx swa deploy
Welcome to Azure Static Web Apps CLI (1.1.7)
Deploying front-end files from folder:
/workspace/out
Consider providing api-language and version using --api-language and --api-version flags,
otherwise default values apiLanguage: node and apiVersion: 16 will apply
Checking Azure session...
✖ Cannot spawn a message bus without a machine-id: Unable to load /var/lib/dbus/machine-id or /etc/machine-id: Failed to open file “/var/lib/dbus/machine-id”: No such file or directory
To Reproduce
Steps to reproduce the behavior:
- Set up a devcontainer based on
mcr.microsoft.com/devcontainers/base:bullseye
- Install swa cli from npm
- run
swa login
orswa deploy
(note: you may need to installlibsecret-1-dev
)
Expected behavior
Successful operation; no error.
Desktop (please complete the following information):
- Host
- OS: Ubuntu 20.04.6 LTS (focal) (64-bit)
- Docker: Docker version 25.0.4, build 1a576c5
- Devcontainer
- OS: Debian 11
- Node: v18.19.1
- NPM: 10.2.4
- SWA: 1.1.7
Additional context
Some solutions suggest exposing the host computer's /var/lib/dbus/machine-id
to the devcontainer. I would prefer not doing so as that does not seem like a cross-platform solution.
This also occurs on Alpine Linux 3.19 after doing 'sudo apk add libsecret'
See https://github.com/adrianhall/swa-alpine-test for repro - just add sudo apk add libsecret before running.
Ref: #858
Can confirm this is still an issue. The solution in the linked thread, installing libsecrets, does not seem to solve the problem in a devcontainer.
This is fixed in v2.0.0 when using azure CLI login:
/workspaces/swa-alpine-test/swa-react-demo $ npx swa login --resource-group adhal-swa-demo --app-name swa-react-demo
(node:5360) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Welcome to Azure Static Web Apps CLI (2.0.0)
Using configuration "swa-react-demo" from file:
/workspaces/swa-alpine-test/swa-react-demo/swa-cli.config.json
Checking Azure session...
✔ Successfully logged into Azure!
✔ Saved project credentials in .env file.
✔ Successfully setup project!
/workspaces/swa-alpine-test/swa-react-demo $
v2.0.0 is out this week; if you can't wait, load from azure/static-web-apps-cli#main.