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

Opening a GitHub repo in a container volume doesn't find the devcontainer setup #6454

Closed
Jademalo opened this issue Mar 15, 2022 · 11 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers verified Verification succeeded volume Dev Container mounting a Docker volume
Milestone

Comments

@Jademalo
Copy link

Jademalo commented Mar 15, 2022

Issue Type: Bug

I have a private GitHub repo. Within this repo, I have a branch that includes a full .devcontainer configuration. If I clone the repo locally and switch to the correct branch, it works correctly in a dev container.

However, if I try to clone it into a container volume, even when selecting the correct branch it fails to find the devcontainer configuration. I have double checked the logs and the branch on GitHub, and I'm definitely selecting the correct branch.
No matter what I do, it says no configuration is found, and opens the auto configuration tool to add a dev container setup.

The container setup isn't included in the default branch, but since I'm selecting the specific branch I want to use when creating the container volume I don't see why that should matter.

[62 ms] Remote-Containers 0.224.2 in VS Code 1.65.2 (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1).
[61 ms] Start: Resolving Remote
[76 ms] Start: Check Docker is running
[76 ms] Start: Run: docker version --format {{.Server.APIVersion}}
[876 ms] Server API version: 1.41
[877 ms] Start: Run: docker volume ls -q
[1711 ms] Start: Run: docker ps -q -a --filter label=vsch.local.repository=https://github.com/Jademalo/WetBlue.git/tree/docker-setup --filter label=vsch.local.repository.volume=WetBlue-docker-setup-99dfe177ed05bcecb4ec83a047846e95 --filter label=vsch.local.repository.folder=WetBlue --filter label=vsch.quality=stable
[2575 ms] Start: Run: docker build -f C:\Users\Scotty\AppData\Local\Temp\vsch\volume.Dockerfile-0.224.2 -t vsc-volume-bootstrap C:\Users\Scotty\AppData\Local\Temp\vsch

[+] Building 0.8s (6/6) FINISHED
 => [internal] load build definition from volume.Dockerfile-0.224.2                                                                                                                                                  0.0s
 => => transferring dockerfile: 188B                                                                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                                                                      0.0s
 => [internal] load metadata for mcr.microsoft.com/vscode/devcontainers/base:0-alpine-3.14                                                                                                                           0.6s
 => [1/2] FROM mcr.microsoft.com/vscode/devcontainers/base:0-alpine-3.14@sha256:f5ae14eb35e030f2dd1cfc86819d011f54da1d0d85db39cc25b0771efccc8b16                                                                     0.0s
 => CACHED [2/2] RUN apk add --no-cache  nodejs  docker-cli  docker-compose  ;                                                                                                                                       0.0s
 => exporting to image                                                                                                                                                                                               0.0s
 => => exporting layers                                                                                                                                                                                              0.0s
 => => writing image sha256:1f6ca721c368e379bbe700a0a8bb498a9138514e93808683abab384fc379b1d6                                                                                                                         0.0s
 => => naming to docker.io/library/vsc-volume-bootstrap                                                                                                                                                              0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
[4679 ms] Cloning Github repository: Jademalo/WetBlue into /workspaces/WetBlue

[4679 ms] Start: Run: docker run -d --mount type=volume,src=WetBlue-docker-setup-99dfe177ed05bcecb4ec83a047846e95,dst=/workspaces -v /var/run/docker.sock:/var/run/docker.sock vsc-volume-bootstrap sleep infinity
[6165 ms] Start: Run in container: /bin/sh
[6196 ms] Start: Launching Remote-Containers helper.
[6196 ms] ssh-agent: SSH_AUTH_SOCK in container (/tmp/vscode-ssh-auth-1713a814656653bdad6645f061baddc7029c30ec.sock) forwarded to local host (\\.\pipe\openssh-ssh-agent).
[6197 ms] Start: Run: gpgconf --list-dir agent-extra-socket
[6252 ms] Start: Run in container: /bin/sh
[6282 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-1713a814656653bdad6645f061baddc7029c30ec.js' >/tmp/vscode-remote-containers-1713a814656653bdad6645f061baddc7029c30ec.js
[7278 ms] 
[7278 ms] 
[7278 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-server-1713a814656653bdad6645f061baddc7029c30ec.js' >/tmp/vscode-remote-containers-server-1713a814656653bdad6645f061baddc7029c30ec.js_1647355331083
[7283 ms] 
[7284 ms] 
[7287 ms] Start: Run in container: # Test for /root/.gitconfig and git
[7289 ms] 
[7289 ms] 
[7290 ms] Start: Run in container: # Copy C:\Users\Scotty\.gitconfig to /root/.gitconfig
[7293 ms] 
[7293 ms] 
[7294 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --global --replace-all credential.helper '!f() { node /tmp/vscode-remote-containers-1713a814656653bdad6645f061baddc7029c30ec.js $*; }; f' || true
[7297 ms] 
[7298 ms] 
[7298 ms] Start: Run in container: # Test for /root/.ssh/known_hosts and ssh
[7301 ms] 
[7301 ms] 
[7302 ms] Start: Run in container: # Copy C:\Users\Scotty\.ssh\known_hosts to /root/.ssh/known_hosts
[7305 ms] 
[7305 ms] 
[7393 ms] Start: Run in container: cat /workspaces/WetBlue/.devcontainer/devcontainer.json 2>/dev/null
[7395 ms] Start: Run in container: cat /workspaces/WetBlue/.devcontainer.json 2>/dev/null
[7398 ms] Repository Jademalo/WetBlue has no development container files.

image

As you can see from the log and the image, this should work. It seems that it doesn't change branch before trying to create the container, so it doesn't find any config.

Extension version: 0.224.2
VS Code version: Code 1.65.2 (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1, 2022-03-10T14:33:55.248Z)
OS version: Windows_NT x64 10.0.22000
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8086K CPU @ 4.00GHz (12 x 4008)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.84GB (14.06GB free)
Process Argv --crash-reporter-id 75d2bff3-b4ef-4cb2-9b19-e7eeeba2b392
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vsclayoutctrt:30451275
dsvsc009:30452663
pythonvspyt640:30450904
vscscmwlcmc:30438804
vscgsvid2:30447481
pynewfile477:30450038

@Jademalo
Copy link
Author

Small further discovery, it seems that it is selecting the correct branch. However, rather than cloning it directly from GitHub it's trying to use a cached version from before that branch had the configuration added.
After going through the wizard and getting a dev container set up, the icon at the bottom left shows two commits available to be pulled, which are the two commits in which I added the configuration.

@github-actions github-actions bot added the containers Issue in vscode-remote containers label Mar 15, 2022
@bamurtaugh
Copy link
Member

Thanks for the details @Jademalo.

It sounds like the issue was ultimately that the cloned version in the volume had the latest commits, but didn't apply them?

@Jademalo
Copy link
Author

Jademalo commented Mar 21, 2022

I did a bit more testing just now, I think I've figured out why this happens.

First, create a container from a remote repo that doesn't have a .devcontainer. When it prompts you to automatically initialise a .devcontainer folder, cancel and have the container build fail.
Second, add the .devcontainer information from a local repo to the remote.
Third, try to build the container volume again using the newly updated branch. This will fail in the same way it did in step 1, not pulling the newly pushed commits from the remote.

What I think is happening is since the container didn't complete building initially, a volume gets created with a clone of the repo. Even if this is changed on the remote, when you try to build the container again it will use this volume and won't try to pull changes nor re-clone the repo.
This means that until the container builds correctly at least once, it will keep trying to resume where it left off and not update the repo from the remote.

Going into docker and deleting the volume that gets created when the repo is pulled forces it to clone again, and correctly gets the up to date repo.

@chrmarti chrmarti added the bug Issue identified by VS Code Team member as probable bug label Mar 22, 2022
@chrmarti chrmarti self-assigned this Mar 22, 2022
@chrmarti chrmarti added the volume Dev Container mounting a Docker volume label Dec 19, 2022
@kiweezi
Copy link

kiweezi commented May 16, 2023

Thanks @Jademalo for the great explanation, saved me some time!

This just happened to me too, for the same reason.
Deleting the volume and running it again, fixed it for me as suggested.

I don't know if or how the solution for this could be implemented.
Maybe it cleans up containers and volumes automatically if the process is canceled before finishing?

@linucks
Copy link

linucks commented Oct 25, 2023

Just experienced this as well. I was trying out devcontainers and forgot to upload the .devcontainer folder. I committed it, pushed, but then couldn't understand why I kept hitting the error.

@Malix-Labs
Copy link

Hey, are you sure it's not related to #9163 ?

@Jademalo
Copy link
Author

It's been two and a half years since I made this issue so I can't remember exactly, but I believe I was using GitHub sign in via VSCode rather than a key pair for authentication to download the private repo

@Malix-Labs
Copy link

Malix-Labs commented Oct 25, 2024

It's basically the same underlying mechanism

Can you reproduce your issue nowadays, or has it been fixed in the meantime ?

@Jademalo
Copy link
Author

I've not used it in a long time, I'll need to find some time to investigate and I'm pretty busy at the moment

@chrmarti
Copy link
Contributor

We can improve this by pulling in the latest changes when rebuilding the container and there are no local changes.

@joshspicer
Copy link
Member

Validated that the latest changes are successfully pulled on rebuilding a dev container cloned into a volume ✅

As mentioned, there needs to be no pending changes for the pull to happen. I wonder if it would be valuable a flow for when the local is dirty. Tracked in #10539

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers verified Verification succeeded volume Dev Container mounting a Docker volume
Projects
None yet
Development

No branches or pull requests

7 participants