Skip to content
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

Add open command to @vscode/dev-container-cli #5957

Open
felipecrs opened this issue Nov 29, 2021 · 8 comments
Open

Add open command to @vscode/dev-container-cli #5957

felipecrs opened this issue Nov 29, 2021 · 8 comments
Assignees
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality
Milestone

Comments

@felipecrs
Copy link

This issue is a follow-up of #5415 (comment).

Now the devcontainer cli is available to be installed from npm with npm install --global @vscode/dev-container-cli, but it's missing the open command.

My use case is to have it installed as part of my dotfiles, so that I get the devcontainer command installed every time I bootstrap a new computer with my dotfiles installation script (which also manages to install VS Code, by the way).

However, I use a similar dotfiles experience as a managed development environment for the my team, and there, I have a guide where I tell them to:

  1. Install our dotfiles to bootstrap their dev env
  2. Clone any of our company's repository
  3. devcontainer open it

But it would be too cumbersome if I had to write instructions like:

  1. First open VS Code
  2. F1 -> Install Devcontainer CLI
  3. Answers the questions on the screen

And then get back to the part where devcontainer open would actually work.

@github-actions github-actions bot added the containers Issue in vscode-remote containers label Nov 29, 2021
@chrmarti chrmarti self-assigned this Nov 30, 2021
@chrmarti chrmarti added this to the Backlog milestone Nov 30, 2021
@chrmarti chrmarti added the feature-request Request for new features or functionality label Nov 30, 2021
@ManfredLange
Copy link

There was a version in the past that supported the open command. It appears to me that this is a case of feature degradation. The documentation at https://code.visualstudio.com/docs/remote/devcontainer-cli the output of devcontainer --help lists a command named open:

$ devcontainer --help
devcontainer <command>

Commands:
  devcontainer open [path]   Open a dev container in VS Code
  devcontainer build [path]  Build a dev container image

Options:
  -h, --help               Show help  [boolean]
      --disable-telemetry  Disable telemetry  [boolean] [default: false]

However, a few days ago and after following the instructions to install it on a new Ubuntu distro (WSL2), the output of devcontainer --help looks as follows:

$ devcontainer --help
devcontainer <command>

Commands:
  devcontainer build [path]  Build a dev container image

Options:
  -h, --help               Show help                                                                           [boolean]
      --disable-telemetry  Disable telemetry                                                  [boolean] [default: false]

As you can see it list only build as a command. open is no longer available.

The build command, which is now the only one currently supported, is not that useful in our setup. Building of the dev container and its dependencies happens automatically via .devcontainer or .devcontainer.json if needed when VS Code opens the directory in the dev container.

@chrmarti
Copy link
Contributor

@ManfredLange There are two ways to install the CLI: As part of the Remote-Containers extension and as an NPM package. Currently the NPM package does not support open because it lacks the association with your VS Code install. This feature request is about improving that.

When you use the CLI installed as part of Remote-Containers, the open command is available. (If it is not, it would be a bug.)

@vike2000
Copy link

vike2000 commented Jan 9, 2022

I just wrote a similar issue before searching and finding this - doh.
My approach, though, was as a bug report on that the feature difference is undocumented. So, if it's not just a quick fix to harmonise features with regards to installation method, I could suggest someone documents these facts, suggestively around "You may also install the CLI from the command line."

It didn't feel right to dump my bug report in the issues after finding this, but let me know if you think it'd help to get it documented.
Thanks for your work. (If documentation is a community effort, feel free to point me in that direction.)

PS. I actually found #2900 before this

@felipecrs
Copy link
Author

https://github.com/microsoft/vscode-docs

@ManfredLange
Copy link

The installation method via the Remote-Container extension in fact installs it..... On my Windows host.

However, I am using WSL2 (Ubuntu 20.04) installed and that is where I want to install the devcontainer-cli. The extension doesn't do that. And when installing via npm then the open-command is missing.

So, while it's useful to know that the devcontainer-cli can be installed via the extension, it doesn't appear in WSL2.

@ManfredLange
Copy link

The installation method via the Remote-Container extension in fact installs it..... On my Windows host.

However, I am using WSL2 (Ubuntu 20.04) installed and that is where I want to install the devcontainer-cli. The extension doesn't do that. And when installing via npm then the open-command is missing.

So, while it's useful to know that the devcontainer-cli can be installed via the extension, it doesn't appear in WSL2.

It does appear, though, when I restart the computer. So the following seems to work:

  1. Install VS Code
  2. Install Remote-container extension
  3. In VS Code from the Command Palette (F1) execute Remote-Containers: Install devcontainer CLI
  4. Reboot your computer
  5. devcontainer --help in a WSL2/Ubuntu terminal should now show option open as well.

This recipe applies to this set up:

  1. Windows 10 or 11
  2. WSL2 with some Linux distro (e.g. Ubuntu)
  3. VS Code
  4. Docker Desktop, configured to use WSL2

@manualbashing
Copy link

@ManfredLange Thanks, that works! In my case, it was enough to restart the WSL with wsl.exe --shutdown. No need to reboot the computer.

@jyasskin
Copy link

jyasskin commented May 2, 2024

In my case, after restarting WSL2, running devcontainer --help returns

wslpath: Invalid argument
Failed to determine Dev Containers path

Has anyone debugged that symptom?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

6 participants