Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel installation sail problem ((23) Failed writing body)

Tags:

docker

laravel

I try to install laravel with the original laravel document but nothing happened, I got many errors, for example I tried this command on CMD;

curl -s https://laravel.build/example-app | bash

but I got this error

(23) Failed writing body

When I tried with PowerShell I got this error;

cmdlet Invoke-WebRequest at command pipeline position 1
Supply values for the following parameters:
Uri:
curl : Cannot find drive. A drive with the name 'https' does not exist.
At line:1 char:1
 curl -s https://laravel.build/example-app | bash
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 CategoryInfo          : ObjectNotFound: (https:String) [Invoke-WebRequest], DriveNotFoundException
 FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Specs;

Docker Engine v20.10.0

Edition Windows 10 Home Version 20H2 Installed on ‎14/‎08/‎2020 OS build 19042.685 Experience Windows Feature Experience Pack 120.2212.551.0

like image 868
Orhan Erday Avatar asked Dec 15 '20 19:12

Orhan Erday


People also ask

What is sail service in laravel?

Laravel Sail is a light-weight command-line interface for interacting with Laravel's default Docker development environment. Sail provides a great starting point for building a Laravel application using PHP, MySQL, and Redis without requiring prior Docker experience.

Can I run laravel without Docker?

If you are beginners and just want to learn laravel 9 running laravel using docker and sail might overwhelm you. You can install and run laravel without using docker environment, First of all you need to have composer installed on your operating system before you create a new laravel project locally.

What is Docker for Laravel?

Docker is a tool used to create containers for applications. These containers are used to package applications so they can run smoothly in any environment (or operating system) without need for any special setup or configuration. Sail provides your Laravel application with a Docker development environment.


2 Answers

I ran into this issue as well and found the (usually excellent) Laravel documentation to be a little vague.

First of all, I have some knowledge of Docker but wanted to get much better acquainted so the recent release of Laravel Sail seemed like an excellent starting point.

  1. Install Docker Desktop https://docs.docker.com/docker-for-windows/install/
  2. Install and enable WSL2 https://learn.microsoft.com/en-us/windows/wsl/install-win10#simplified-installation-for-windows-insiders
  3. The Laravel docs mention this in above step but the part I missed was installing a Linux distribution at the same time (via the Microsoft Store). I assumed Sail took care of this part.
  4. Goto the windows store a get your distro e.g. Ubuntu 20.04 (https://www.microsoft.com/en-gb/p/ubuntu-2004-lts/9n6svws3rx71?rtc=1)
  5. Install Windows Terminal - https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701?rtc=1&activetab=pivot:overviewtab. Up until now, I was using Cmder or ConEmu rather than the Command Prompt. The important difference is you can start a new shell for windows or any of the Linux distributions you have installed. Again, I assumed you could use the curl -s https://laravel.build/example-app | bash command in my windows Cmder - not the case.
  6. Start up a new Linux shell and if you ls you'll see your Windows filesystem. From there I cd'd to my projects directory, ran curl -s https://laravel.build/example-app | bash and that took care of the rest.

One caveat is that you may have to enable any downloaded Linux distributions in Docker:

Enabling WSL2 in docker for Linux distributions

Of course, the process makes sense when you solve it and Sail does offer some useful shortcuts in getting a Laravel project up and running quickly with Docker but complete newcomers could be forgiven for thinking it takes care of absolutely everything - which it doesn't.

Side note

The reason you were getting the error in PowerShell is because PS has an alias for curl but not the curl you expect. (cURL in power shell windows 8.1: "A drive with the name 'localhost' does not exist")

You can permanently remove this (https://github.com/lukesampson/scoop/issues/56#issuecomment-609098474) but you may not need to now you know how to use the command in your Linux shell.

like image 153
Chris J Avatar answered Oct 25 '22 08:10

Chris J


The solution above provided by @chris-j works like a charm, but if you still get the error "Docker in not running" even if the it's green consider doing the following

  • Do sudo su and then curl -s https://laravel.build/example-app | bash
like image 1
Ayoub Bousetta Avatar answered Oct 25 '22 06:10

Ayoub Bousetta