WSL2 with Docker Desktop: 在 $PATH 中找不到 ddev.exe,请在 Windows 端安装它;

huangapple go评论63阅读模式
英文:

WSL2 with Docker Desktop: ddev.exe not found in $PATH, please install it on Windows side;

问题

我正在尝试使用命令 ddev start 启动一个 ddev 环境,但我一直收到错误消息 ddev.exe not found in $PATH please install it on Windows side; err=exec: "ddev.exe": executable file not found in $PATH。我已经按照 ddev 网站 上的安装说明进行安装。然而,错误仍然存在。

这是 ddev debug test 的完整输出:

https://gist.github.com/webseppel/a2c8b4133f14b83fde05b0b8d2972f28

在 Windows 环境中:

ddev -v
ddev version v1.21.6

docker version
Client:
 Cloud integration: v1.0.33
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:53:15 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.20.1 (110738)
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:52:17 2023
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

在 WSL2 环境中:

ddev -v
ddev version v1.21.6
英文:

I am trying to start a ddev environment using the command ddev start, but I keep getting the error message ddev.exe not found in $PATH please install it on Windows side; err=exec: "ddev.exe": executable file not found in $PATH. I followed the installation instructions on ddev website. However, the error still persists.

This is the full output of ddev debug test:

https://gist.github.com/webseppel/a2c8b4133f14b83fde05b0b8d2972f28

On Windows side:

ddev -v
ddev version v1.21.6

docker version
Client:
 Cloud integration: v1.0.33
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:53:15 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.20.1 (110738)
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:52:17 2023
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

In WSL2:

ddev -v
ddev version v1.21.6

答案1

得分: 0

欢迎来到DDEV,@Seppel。

这里有一些问题。

你似乎正在使用Docker Desktop安装WSL2上的DDEV,这很好。

  1. 通常情况下,在Windows上不需要使用ddev.exe来处理正常的项目(使用*.ddev.site),因为不需要编辑hosts文件。如果你正在处理一个没有更改project_tldadditional_fqdns的项目,那么它应该不会生效。对于一些无法解析*.ddev.site的人来说,比如拥有Fritzbox路由器的人,它确实会生效。你可以在https://ddev.readthedocs.io/en/latest/users/usage/troubleshooting/#ddev-starts-but-browser-cant-access-url 上阅读更多信息。

  2. 但是,假设需要编辑hosts文件,你需要在Windows上安装DDEV并将其添加到PATH中。现在它并没有在你的PATH中。也许Chocolatey安装失败了,或者安装后需要重新启动。但是你可以使用管理员用户choco install -y ddev来安装它,或者使用发布页面上的安装程序。

当你可以在Windows侧的PowerShell、Cmd或Git Bash窗口中输入ddev.exe --version而不出现错误时,你可能已经成功了。

但我看到你已经能够做到这一点。

所以...也许你的WSL2发行版没有正确设置路径。你应该能够在WSL2中输入ddev.exe --version并使其正常工作。如果不行,那么你的WSL2中的PATH可能不正确。在一个示例的WSL2/Docker Desktop设置中,我看到了这个:

$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Git/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Users/testbot/AppData/Local/Microsoft/WindowsApps:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/DDEV:/Docker/host/bin:/mnt/c/Users/testbot/AppData/Roaming/Composer/vendor/bin:/mnt/c/Users/testbot/go/bin:/mnt/c/Users/testbot/AppData/Roaming/npm:/snap/bin:/home/linuxbrew/.linuxbrew/bin

其中关键的部分是/mnt/c/Program Files/DDEV - 这个路径元素可以让你从WSL2中找到ddev.exe。你可以手动将其添加到你的.profile或.bash_profile文件中,但通常会从Windows设置中继承到WSL2中。

英文:

Welcome to DDEV @Seppel.

There are a couple of problems here.

You seem to be installing DDEV for WSL2 with Docker Desktop, which is great.

  1. Normally, ddev.exe on the Windows side is not used for a normal project, (one that uses *.ddev.site) because the hosts file does not need to be edited. If you're doing a project that doesn't have a changed project_tld or additional_fqdns then this should never come into play. It does come into play with some people who have Fritzbox routers or otherwise can't resolve *.ddev.site. You can read about this at https://ddev.readthedocs.io/en/latest/users/usage/troubleshooting/#ddev-starts-but-browser-cant-access-url
  2. But assuming that the hosts file does need to be edited, you need DDEV installed and in your PATH on the Windows side. Right now it's not in your PATH. Perhaps the Chocolatey installation failed, or perhaps you needed to reboot after installation. But you can, as admin user choco install -y ddev to install it, or use the installer from the releases page.

When you can type ddev.exe --version on your PowerShell or Cmd or Git Bash window on the Windows side and not get an error, you're probably there.

But I see you were already able to do that.

So... Perhaps your WSL2 Distro is not set up with the path correctly. You should be able to type ddev.exe --version in WSL2 and get it to work. If it doesn't your PATH in there may not be right. On an example WSL2/Docker Desktop setup I see this:

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Git/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Users/testbot/AppData/Local/Microsoft/WindowsApps:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/DDEV:/Docker/host/bin:/mnt/c/Users/testbot/AppData/Roaming/Composer/vendor/bin:/mnt/c/Users/testbot/go/bin:/mnt/c/Users/testbot/AppData/Roaming/npm:/snap/bin:/home/linuxbrew/.linuxbrew/bin

The key thing there is /mnt/c/Program Files/DDEV - that element in the PATH lets you find ddev.exe from WSL2. You can add it manually to your .profile or .bash_profile or whatever, but it would normally be inherited by WSL2 from Windows setup.

huangapple
  • 本文由 发表于 2023年6月16日 16:04:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76488142.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定