[英]laravel/docker project env: bash\r: No such file or directory
I know, I know this question has been discussed a million times but please here me out.我知道,我知道这个问题已经被讨论了一百万次,但请告诉我。 So I am brand new to using docker/sail with Laravel I am creating my first ever project with that.
所以我对使用 docker/sail 和 Laravel 非常陌生,我正在用它创建我的第一个项目。 I have coded using Laravel for probably 8 years now and had always used WAMP.
我已经使用 Laravel 编码大概 8 年了,并且一直使用 WAMP。 I am running Windows 11.
我正在运行 Windows 11。
So to the problem when I try to start up my container using sail up or docker desktop I have 3 (not even sure I am using the correct terminology here) but I have 3 sections/services in my docker-compose.yml file.因此,当我尝试使用sails up 或 docker 桌面启动容器时,我有 3 个(甚至不确定我在这里使用的术语是否正确),但我的 docker-compose.yml 文件中有 3 个部分/服务。 redis, mysql and laravel.test.
redis、mysql 和 laravel.test。 The redis and mysql startup fine and show the green icon in docker desktop.
redis 和 mysql 启动正常,并在 docker 桌面上显示绿色图标。 But the laravel.test shows the following error in the log: /usr/bin/env: 'bash\r': No such file or directory
但是 laravel.test 在日志中显示以下错误: /usr/bin/env: 'bash\r': No such file or directory
Now I have read 100 other threads discussing this and most all of them talk about the line endings and needing to switch to Unix line endings.现在我已经阅读了 100 个其他讨论这个问题的线程,并且大多数人都在谈论行尾并需要切换到 Unix 行尾。 So I have tried every thing in the books.
所以我尝试了书中的每一件事。 I have removed the entire git repo, then ran git config --global core.autocrlf false then cloned the project again and I still get the same error.
我已经删除了整个 git 存储库,然后运行 git config --global core.autocrlf false 然后再次克隆项目,我仍然得到同样的错误。 I then used my editor (phpStorm) and made sure the preferences were set to use unix line endings and then ran a script to change all the files with correct line ending.
然后我使用我的编辑器 (phpStorm) 并确保将首选项设置为使用 unix 行尾,然后运行脚本以更改所有具有正确行尾的文件。 I still get the same error.
我仍然得到同样的错误。
So my question is how can I dig deeper into Laravel/docker/sail and determine what is actually generating the error and how can I pinpoint the line causing the error?所以我的问题是如何深入研究 Laravel/docker/sail 并确定实际产生错误的原因以及如何查明导致错误的行? How can I determine what script/file is generating this error that is trying to find /usr/bin/env in the first place?
我如何确定哪个脚本/文件首先生成了这个试图查找 /usr/bin/env 的错误?
I am so lost as this is all so new to me.我很迷茫,因为这对我来说太新鲜了。
Installing to the WSL VM Home安装到 WSL VM 主页
Following the Laravel documentation for installing laravel with Windows .按照 Laravel 文档安装laravel 和 Windows 。 Laravel should be installed from inside a new WSL terminal session with
curl -s https://laravel.build/example-app | bash
Laravel should be installed from inside a new WSL terminal session with
curl -s https://laravel.build/example-app | bash
curl -s https://laravel.build/example-app | bash
. curl -s https://laravel.build/example-app | bash
。 This documentation hints that the project should be installed and located in the WSL VM home.该文档提示应安装该项目并将其定位在 WSL VM 主页中。
A similar question suggests running docker containers from within WSL by moving the project to the VM home.一个类似的问题建议通过将项目移动到 VM 主页,从 WSL 中运行 docker 容器。 In many cases this is located
\\wsl$\Ubuntu-20.04\home\username\project
.在许多情况下,它位于
\\wsl$\Ubuntu-20.04\home\username\project
。
Sail Commands航行命令
The container may need to be rebuilt after the move.移动后可能需要重建容器。 This can be accomplished with the
sail build --no-cache
command.这可以通过
sail build --no-cache
命令来完成。
If no alias is set yet the sail commands may be accessed with vendor/bin/sail {command}
如果还没有设置别名,则可以使用
vendor/bin/sail {command}
访问sai 命令
The following is a list of resources that can be used:以下是可以使用的资源列表:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.