LoginSignup
1
1

VSCode の Dev Containers で `err: exec: "docker-credential-desktop.exe": executable file not found in $PATH` が発生

Posted at

環境

vscode
バージョン: 1.82.0 (user setup)
コミット: 8b617bd08fd9e3fc94d14adb8d358b56e3f72314
日付: 2023-09-06T22:07:07.438Z
Electron: 25.8.0
ElectronBuildId: 23503258
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045
  • WSL2 (Ubuntu)
  • Dev Containers v0.309.0

背景

devcontainer を使って既存のコンテナアプリをセットアップしたところ、以下のエラー。

ERROR: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exec: "docker-credential-desktop.exe": executable file not found in $PATH, out: ``

対応

~/.docker/docker.json の credsStore を credStore に修正

自分の環境では解消せず

WSL2 のデフォルトユーザーを使う

ログをよくよく見ると:

[2023-09-11T03:43:18.895Z] userEnvProbe is taking longer than 2 seconds. Process tree:
  7824: /bin/bash -lic echo -n 05039aae-16c0-4d24-81a5-233b1f0bb6f8; cat /proc/self/environ; echo -n 05039aae-16c0-4d24-81a5-233b1f0bb6f8 
    7850: su - t_ogawa 
      7851: -su 

→ userEnvProbe に時間がかかっている。また、su による子プロセスが表示されている

[2023-09-11T03:43:27.482Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl$\Ubuntu1804\home\t_ogawa\dev\foo --filter label=devcontainer.config_file=/home/t_ogawa/dev/foo/.devcontainer/devcontainer.json
[2023-09-11T03:43:27.667Z] Stop (185 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl$\Ubuntu1804\home\t_ogawa\dev\foo --filter label=devcontainer.config_file=/home/t_ogawa/dev/foo/.devcontainer/devcontainer.json
[2023-09-11T03:43:27.684Z] Stop (581 ms): Run in Host: /root/.vscode-server/bin/8b617bd08fd9e3fc94d14adb8d358b56e3f72314/node /root/.vscode-remote-containers/dist/dev-containers-cli-0.309.0/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /home/t_ogawa/dev/foo --id-label devcontainer.local_folder=\\wsl$\Ubuntu1804\home\t_ogawa\dev\foo --id-label devcontainer.config_file=/home/t_ogawa/dev/foo/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/t_ogawa/dev/foo/.devcontainer/devcontainer.json --mount-workspace-git-root true
[2023-09-11T03:43:27.697Z] Start: Run in Host: /root/.vscode-server/bin/8b617bd08fd9e3fc94d14adb8d358b56e3f72314/node /root/.vscode-remote-containers/dist/dev-containers-cli-0.309.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-0e6f723f-e99d-4c53-bdc1-52bbc458c3261694403793680 --workspace-folder /home/t_ogawa/dev/foo --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl$\Ubuntu1804\home\t_ogawa\dev\foo --id-label devcontainer.config_file=/home/t_ogawa/dev/foo/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/t_ogawa/dev/foo/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true --terminal-columns 169 --terminal-rows 24

→ root ユーザーで処理が行われている。

普段開発時に利用しているのは useradd して作った t_ogawa ユーザーだった。
WSL2 の OS セットアップ時に、誤って root をデフォルトユーザーとしてしまった経緯があり、root の rc file をいじってログイン時に su - t_ogawa するようにしていたのが原因だった。

本来、こういうときは /etc/wsl.conf に以下のような項目を追加するべき。

[user]
default=t_ogawa

su しないようにして、代わりに上記のような wsl.conf を設定したところ、エラーは解消された。

セオリー通りにやらないとこういったしっぺ返しを受けるという好例であった。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1