jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.83k stars 187 forks source link

CLI Login Prompt has weird interactions with VSCode extension #2115

Open Lagoja opened 1 month ago

Lagoja commented 1 month ago

What happened?

Problem Description

This issue arises when:

  1. A project is configured to use Jetify Secrets
  2. The user is not logged in
  3. The user attempts to use the Reopen in Devbox Shell feature in our VSCode Extension

The Reopen in Devbox Shell feature will attempt to start a shell in the background in order to reopen VSCode in the correct environment. However, since the current flow forces users to login if they have Devbox Secrets configured, and our extension does not provide a prompt for this login, the extension hangs indefinitely. We do open a browser window to login, but the user does not receive a prompt for why the browser window was opened.

Closing or cancelling the Reopen step does not terminate the background devbox process, and the running process will bind the address required to login. This means developers cannot login until they pkill the running process, or until they complete the login steps for the background devbox process

❯ devbox install
Info: Ensuring packages are installed.
Warning: Outputs for nixpkgs#darwin.apple_sdk.frameworks.SystemConfiguration are not in lockfile. Fetching store paths from nix, this may take a while
✓ Computed the Devbox environment.
You are not logged in.
Press Enter to open your browser and login...
Error: listen tcp 127.0.0.1:4446: bind: address already in use

Since it's not clear to the user why the Reopen in Devbox failed (no error message, no warning, no prompt), the user is unlikely to know how to resolve this issue.

Proposed Solution

We should never block devbox shell or other commands just because the user is logged out. A user may have valid reasons for logging out of Jetify Secrets -- e.g., they want to use a local .env file instead, or they may want to make the project available to users who don't have access to their secrets.

Instead, we should display a warning that the project is configured for Devbox Secrets, and that the user should login to use Secrets. This warning should be non blocking.

Steps to reproduce

Repro steps require VSCode with the Devbox Extension installed

  1. Login with devbox auth login
  2. Configure a project to use secrets with devbox secrets init
  3. Logout with devbox auth logout
  4. Open the project in VSCode, attempt to Reopen the Project in Devbox Shell. Note that a browser window will open without any prompt or explanation.
  5. Reopen step will hang with no messaging or information from the extension
  6. Cancel the extension by clicking the Cancel button in the notification
  7. Attempt to login with devbox auth login. You will get a bind error, the browser will relaunch, but signing in to the browser will not log you in (since it's pointing to the running session of Devbox).

Command

install, run, services, shell

devbox.json

{
  "packages": [
    "go@1.20"
  ],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  },
  "env_from": "jetpack-cloud"
}

Devbox version

0.11.0

Nix version

No response

What system does this bug occur on?

macOS (Apple Silicon)

Debug logs

No response