Skip to content

[vscode-extension] reopen vscode in devbox env using process communication #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jun 15, 2023

Conversation

mohsenari
Copy link
Collaborator

@mohsenari mohsenari commented Jun 1, 2023

Summary

Added ability to reload a vscode window and re-open it in a devbox environment.
This is done in 4 steps:

  1. Devbox extension invokes devbox CLI (devbox integrate vscode) as a child process.
  2. CLI then prepares the devbox environment (computeNixEnv) and sends a message to parent process that preparing new environment is finished and ready.
  3. Parent process (vscode window) upon receiving the finish message, closes itself.
  4. CLI will open a new vscode window (cmd.execute) with env variables it has received from setting up devbox environment.

NOTE: This required changes to both CLI and the extension, so the release of extension has to happen after CLI.

Addresses #1029

How was it tested?

  1. compile CLI and put the binary in an directory with devbox.json (let's call it vstest/)
  2. specify a package (e.g., hello@latest) and an env variable in devbox.json (e.g., "foo": "bar123")
  3. in devbox.ts update const devbox = 'devbox'; to const devbox = <absolute path to compiled CLI binary>
  4. cd devbox/vscode-extension then package an installable extensinon file: vsce package.(this will create a devbox-version.vsix file)
  5. install this extension on vscode by code --install-extension path-to-vsix-file
  6. open vstest/ in vscode.
  7. In vscode's terminal run echo $foo it should be empty. Then type which hello and it should point to devbox environment's hello, or say command not found
  8. open command palette in vscode (cmd + shift + p) and type "reopen in devbox" and choose the suggested action.
  9. once vscode is re-opened, try step 7 and confirm that vscode now has devbox environment setup.

@mohsenari mohsenari force-pushed the mohsen--extension-env-daemon branch 2 times, most recently from 75274d2 to 32b31de Compare June 13, 2023 14:58
@mohsenari mohsenari requested review from loreto, savil and LucilleH June 13, 2023 17:07
@mohsenari mohsenari changed the title WIP: [vscode-extension] reopen vscode in devbox env using process communication [vscode-extension] reopen vscode in devbox env using process communication Jun 13, 2023
Copy link
Collaborator

@LucilleH LucilleH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

});
}
// change this to absolute path to custom compiled devbox when testing
const devbox = 'devbox';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would have to be something else for prod?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LucilleH No, for testing locally on a compiled devbox this would have to point to the path to the compiled devbox.
This comment is mostly a note-to-self for future changes.
For example, if I change something in CLI and want to see how it interacts with the extension, I should change this line to /Users/mohsen/projects/devbox/dist/devbox so that my changes in compiled devbox CLI gets used instead of the installed devbox. Hope that makes sense.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, To use a custom compiled devbox when testing, change this to an absolute path. lol

@mohsenari mohsenari force-pushed the mohsen--extension-env-daemon branch from 55db3c1 to 55e10bf Compare June 14, 2023 21:13
@mohsenari mohsenari force-pushed the mohsen--extension-env-daemon branch from 8cf4d99 to 6e1d7ca Compare June 15, 2023 15:53
@mohsenari mohsenari merged commit 462211d into main Jun 15, 2023
@mohsenari mohsenari deleted the mohsen--extension-env-daemon branch June 15, 2023 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants