Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
594 stars 117 forks source link

`swa [login|deploy]` fails with `Cannot spawn a message bus without a machine-id` in devcontainer #820

Closed FelixZY closed 2 months ago

FelixZY commented 6 months ago

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:

  1. Set up a devcontainer based on mcr.microsoft.com/devcontainers/base:bullseye
  2. Install swa cli from npm
  3. run swa login or swa deploy (note: you may need to install libsecret-1-dev)

Expected behavior Successful operation; no error.

Desktop (please complete the following information):

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.

adrianhall commented 3 months ago

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

sipkode commented 2 months ago

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.

adrianhall commented 2 months ago

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.