Open koonpeng opened 2 years ago
@chrmarti we use the canonical URI to open the local folder if it exists, is there an issue with that mechanism?
@Tyriar That points to a workspace file because the URI passed in does so too. I think that's how the canonical URI is supposed to work (/cc @lszomoru). Maybe you could apply the same logic you apply when opening a terminal in a multi-root workspace locally? Or use the workspace file's folder as the cwd?
Ah I missed the multi-root part, will investigate to see if we can handle it on our end.
+1 It will be nice if I could open a Local PS7 terminal while inside a devcontainer. I found it was also requested in here (+ a workaround if you have SSH to the host): https://stackoverflow.com/questions/71145541/how-to-open-local-terminal-when-running-vscode-in-a-dev-container
+1. It repros for a multi-root workspace here as well. My workaround is to right-click on a folder and "open in integrated terminal".
I cannot reproduce this anymore, I do see https://github.com/microsoft/vscode/issues/148572 in the multi-root repo as well though.
I have encountered this recently in a multi-root workspace with lots of folders, and the listed workaround doesn't seem to work for me. I wasn't able to reproduce with the minimal example though, so I'll try to see what's different in my current setup and post here if/when I have a minimum reproduction.
Okay, I came up with what I think is close to a minimal reproduction — perhaps part of the problem is that I'm using a non-root user in the container (as described in https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_creating-a-nonroot-user)?
My workspace structure looks like this:
$ tree -a
.
├── .devcontainer
│ ├── Dockerfile
│ └── devcontainer.json
├── subdir
└── workspace.code-workspace
And file contents as follows:
workspace.code-workspace
:
{
"folders": [
{ "name": "top", "path": ".", },
{ "path": "subdir" },
],
"settings": {
"files.exclude": {
"subdir": true,
},
},
}
Dockerfile
:
ARG CODENAME=buster
FROM --platform=linux/amd64 buildpack-deps:$CODENAME
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN mkdir -p /workspaces && chmod 777 /workspaces
RUN apt-get update -y && apt-get -y install sudo
# Setup user + passwordless sudo
RUN groupadd --gid $USER_GID $USERNAME && \
useradd -s /bin/bash --uid ${USER_UID} --gid $USERNAME -m $USERNAME && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME
# running go install as root will prevent the vscode user from installing go packages
RUN su - vscode -c "echo 'cool, setup worked!'"
devcontainer.json
:
{
"build": {
"args": {
"CODENAME": "buster",
"USERNAME": "vscode",
"USER_GID": "1000",
"USER_UID": "501"
},
"dockerfile": "Dockerfile"
},
"containerUser": "vscode",
"remoteUser": "vscode",
"updateRemoteUserUID": true
}
Some additional details that might help: I'm using colima
on macOS for my docker backend:
$ colima version
colima version 0.5.2
git commit: 6b5b6fe0540e708f0c9d6e8919fab292c671fc72
runtime: docker
arch: x86_64
client: v20.10.21
server: v20.10.20
$ limactl --version
limactl version 0.14.2
VSCode (ms-vscode-remote.remote-containers@0.266.1
):
Version: 1.74.3
Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Date: 2023-01-09T17:07:18.579Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin x64 21.6.0
Sandboxed: No
@Tyriar are you able to reproduce with these conditions? Should this issue be reopened? The workaround posted above doesn't seem to work for me, meaning (as far as I can tell) there is no way to open a local terminal in the same window using this kind of environment.
@ian-h-chamberlain we have changes coming in the next version for https://github.com/microsoft/vscode/issues/148572 which might fix your problem. Can you check on insiders? https://code.visualstudio.com/insiders
Unfortunately it appears I can still reproduce on insiders (assuming this version is recent enough to contain those changes? Installed from homebrew with brew install visual-studio-code-insiders
):
Version: 1.75.0-insider
Commit: 07d6f5b35fac559504dec65e3073d796b2d25a55
Date: 2023-01-26T05:22:17.192Z
Electron: 19.1.9
Chromium: 102.0.5005.194
Node.js: 16.14.2
V8: 10.2.154.23-electron.0
OS: Darwin x64 21.6.0
Sandboxed: Yes
The terminal process failed to launch: Starting directory (cwd) "/Users/ichamberlain/Documents/repro/microsoft-vscode-140186-devcontainer-open-local-terminal/workspace.code-workspace" is not a directory.
@ian-h-chamberlain can you share your settings files for the .code-workspace
file as well as the user settings.json?
The .code-workspace
is still the same as I posted in https://github.com/microsoft/vscode/issues/140186#issuecomment-1405216556
Edit: I can reproduce with "vanilla" user config as well (i.e. settings.json
only contains {}
).
For user settings, I'd prefer not to share the entire config if possible, but these are the settings I have for dev.containers
(are there any other important settings I should look for as well? maybe I can try to reproduce with "clean slate" settings as well)
// I was also able to reproduce with empty list here:
"dev.containers.defaultExtensions": [
"asvetliakov.vscode-neovim",
"bierner.markdown-checkbox",
"eamodio.gitlens",
"GitHub.vscode-pull-request-github",
"Gruntfuggly.todo-tree",
"joshuapoehls.json-escaper",
"ms-azuretools.vscode-docker",
"richie5um2.vscode-sort-json",
"sleistner.vscode-fileutils",
"streetsidesoftware.code-spell-checker",
"timonwong.shellcheck",
"Tyriar.sort-lines",
],
"dev.containers.repositoryConfigurationPaths": [
"/Users/ichamberlain/.config/vscode/devcontainers",
"/Users/ianchamberlain/.config/vscode/devcontainers",
],
Steps to Reproduce:
Create a minimal workspace and devcontainer file
workspace.code-workspace
.devcontainer/devcontainer.json
Select
Open Workspace in container
command in the command panel, then selectTerminal: Create New Integrated Terminal (local)
.The terminal fails to open and an error popup shows up:
As a workaround, opening the workspace indirectly via
Open Folder in container
, thenOpen Workspace From File
, results in working local terminal.Does this issue occur when you try this locally?: No Does this issue occur when you try this locally and all extensions are disabled?: No