12

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

ORHAN ERDAY
  • 1,020
  • 8
  • 31

2 Answers2

24

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Chris J
  • 552
  • 2
  • 7
  • 14
  • I typed the command curl -s https://laravel.build/example-app | bash but nothing happens. Did you solve your problem? – themhz Jun 28 '22 at 11:51
1

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
Ayoub Bousetta
  • 176
  • 2
  • 6