Azure / static-web-apps-cli

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

Cannot autolaunch D-Bus without X11 $DISPLAY on GitHub Codespaces (deploy) #575

Open iMicknl opened 1 year ago

iMicknl commented 1 year ago

Before filing this issue, please ensure you're using the latest CLI by running swa --version and comparing to the latest version on npm.

Are you accessing the CLI from the default port :4280 ?

Make sure you are accessing the URL printed in the console when running swa start!

ℹ️ NOTE: Make sure to enable debug logs when running any swa commands using --verbose=silly

Describe the bug When running swa deploy on GitHub Codespaces, I face the following error. ✖ Cannot autolaunch D-Bus without X11 $DISPLAY. This is not documented, so I am not sure what I miss and if GitHub Codespaces is just not supported.

To Reproduce Steps to reproduce the behavior:

  1. Go to GitHub Codespaces
  2. Install latest CLI version
  3. Run npx swa deploy
  4. See error

Expected behavior Deployment using the credentials of Azure CLI, where I am already logged in with.

Desktop (please complete the following information):

Additional context

@iMicknl ➜ /workspaces/semantic-search-demo (main) $ npx swa deploy

Welcome to Azure Static Web Apps CLI (1.0.2)

Using configuration "semantic-search-demo" from file:
  /workspaces/semantic-search-demo/swa-cli.config.json

Deploying front-end files from folder:
  /workspaces/semantic-search-demo/app/build

Deploying API from folder:
  /workspaces/semantic-search-demo/api

Checking Azure session...
✖ Cannot autolaunch D-Bus without X11 $DISPLAY
@iMicknl ➜ /workspaces/semantic-search-demo (main) $ npx swa deploy --verbose=silly

Welcome to Azure Static Web Apps CLI (1.0.2)

Getting config file options from swa-cli.config.json...
Changed directory to /workspaces/semantic-search-demo
Using configuration "semantic-search-demo" from file:
  /workspaces/semantic-search-demo/swa-cli.config.json

Deploying front-end files from folder:
  /workspaces/semantic-search-demo/app/build

Deploying API from folder:
  /workspaces/semantic-search-demo/api

No deployment token found. Trying interactive login...
Checking Azure session...
Executing authenticateWithAzureIdentity
- details:
  - tenantId: <undefined>
  - clientId: <undefined>
  - clientSecret: <undefined>
 - useKeychain: true
Keychain is enabled
Executing swaCliPersistencePlugin
Executing before cache access plugin
Machine ID: <hidden>
Invoking crypto service
Getting credentials
Getting credentials from native keychain
Getting keychain reference
isKeychainEnabled: true
KeychainCache: undefined
Attempting to load native keychain
Executing after cache access plugin
Machine ID: <hidden>
Invoking crypto service
Did TokenCacheContext cache changed: false
After cache access plugin. Done.
✖ Cannot autolaunch D-Bus without X11 $DISPLAY
manekinekko commented 1 year ago

Can you try these options in the following order and let us know which one worked for you:

  1. Disabling Keychain access using --no-use-keychain. For instance: swa deploy --no-use-keychain.
  2. Or, manually provide the Deployment Token for your current project (see SWA CLI docs). You will also need to provide --app-name and --resource-group
  3. Or, manually provide --client-id, --client-secret, --app-name and --resource-group.

Please let us know which option worked for you so we can update the docs.

iMicknl commented 1 year ago

@manekinekko what is the intended audience of the deploy command? I am migrating from 0.x to 1.x and using swa deploy on CodeSpaces is giving me a hard time.

  1. First the issue mentioned here.
  2. While using swa deploy -d token, I bump into a size limit. Removing "azure-functions-core-tools": "^4.x",. from my devDependencies solves this, but not my desired solution.
  3. Using swa deploy --no-use-keychain seems to work, but while choosing the tenant it won't provide me the name. Only the tenant id. Choosing the tenant requires me to log in again and then it seems to work. (until it tells me that it is linked to GitHub, even though the previous deployment to preview worked via swa deploy -d token.
  4. Trying swa deploy -d token again works and deploys the same version to preview. (it does not run / prompt for swa build first, thus I forgot). Running swa build and swa deploy -d token works with the newest version now.

I would say that this CLI would especially be targetted for devs, for example using CodeSpaces, without having to do a lot of extra steps. Having an easy way to deploy a sample they download from GitHub, without configuring CI/CD etc. Is the feedback above valuable / already known?

Regarding this issue, option 2 seems to work (without providing the app name and resource group by the way).

faxg commented 1 month ago

Hey, is there any update on this? Trying to run swa cli inside a Github Codespace and this seems to be needed for login / deploy etc. It would be great to add a section on Codespaces / devcontainers and SWA tool to the docs, documenting the setup, port forwarding etc..