Laravel installation sail problem ((23) Failed writing body) - 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

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.
Install Docker Desktop https://docs.docker.com/docker-for-windows/install/
Install and enable WSL2 https://learn.microsoft.com/en-us/windows/wsl/install-win10#simplified-installation-for-windows-insiders
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.
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)
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.
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:
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.

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

Related

Cant Install Laravel with Docker on Windows WSL

I can't seem to install the new laravel with Docker Desktop on Windows 10.
What I did so far:
I installed Docker Setup with WSL2.
then I installed Ubuntu Distro from Ms Store.
then on command prompt terminal I run wsl command then when I tried to run curl -s "https://laravel.build/example-app" | bash I got this error -sh: curl: not found.
I can't event use the apt command, it gives the same error.
The only working command is ls
WSL integration options on Docker Desktop are already checked
Am I missing something here? How to fix this?
It looks like the curl command is not installed in your Ubuntu WSL distribution. You can install it by running the following command in your WSL terminal:
sudo apt-get update
sudo apt-get install curl
This should install curl and allow you to run the curl command to download the Laravel installer script.
If you're still having trouble using apt, it's possible that your Ubuntu WSL distribution is not properly installed or configured. You may want to try reinstalling or resetting it.
Once you have curl installed, try running the Laravel installer script again with the curl command:
curl -s "https://laravel.build/example-app" | bash
This should create a new Laravel application in a directory called example-app.
If you're still having trouble, you can try using the Docker image for Laravel instead of installing it directly on your machine. The official Laravel Docker image includes everything you need to get started with Laravel in a containerized environment.

Docker is not running when trying to curl laravel

I am trying to set up Docker and Laravel 9 (both for the first time) on my Windows 10 system by following the instructions on the official Laravel website.
I have successfully installed Docker Doesktop and have also successfully installed and activated Windows Subsystem for Linux 2 (WSL2).
I then installed Windows Terminal, connect to an Ubuntu 22.04 container that I have started and tried to run the following command as instructed on the official Laravel website:
curl -s https://laravel.build/example-app | bash
But instead of creating a new project example-app, I get the following message instead:
Docker is not running.
What am I doing wrong?
Ok so I finally figured it out. When I open Windows Terminal, I need to first run wsl and then go forward with curl-ing Laravel and using it.
So after installing and activating WSL2 in Windows & Docker Desktop, the steps to follow would be:
In your terminal, run wsl.
Run the curl -s https://laravel.build/example-app | bash command.
cd to the the new Laravel application example-app directory and then use Laravel Sail to run it.

How do I fix "The term 'sh' is not recognized as the name of a cmdlet, function, script file, or operable program." while installing k3s?

I am new to kubernetes and docker. I have been trying to install k3s on my Windows 10 system with the command mentioned on the website:
curl -sfL https://get.k3s.io | sh -
I already have minikube, kubectl and docker installed on my system, and all work as expected.
However, when I run the above command, I get the following error message:
sh : The term 'sh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:32
+ curl -sfL https://get.k3s.io | sh -
+ ~~
+ CategoryInfo : ObjectNotFound: (sh:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
What am I doing wrong here?
For the time being k3s doesn't support Windows, but there is an open issue on Github you can track.
The installation script you are trying to run, simply won't work on Windows machine. If you take a closer look at the installation requirements section in the very same documentation, you will see the following information, regarding to the supported Operating Systems:
Operating Systems
K3s is expected to work on most modern Linux systems. 👈
Some OSs have specific requirements:
If you are using Raspbian Buster, follow these steps
to switch to legacy iptables.
If you are using Alpine Linux, follow these steps
for additional setup.
If you are using (Red Hat/CentOS) Enterprise Linux, follow these
steps
for additional setup.
For more information on which OSs were tested with Rancher managed K3s
clusters, refer to the Rancher support and maintenance
terms.
So for running k3s on Windows you would need a Linux VM which can be provisioned using a hypervisor like Hyper-V or VirtualBox that can be run on your Windows host.
Take a look at the following article that presents how it can be done by using Hyper-V:
Rancher 2.4 & Kubernetes on your Windows 10 laptop with multipass & k3s — Elasticsearch/Kibana in minutes!

Unable to run cygwin in Windows Docker Container

I've been working with Docker for Windows, attempting to create a Windows Container that can run cygwin as the shell within the container itself. I haven't had any luck getting this going yet. Here's the Dockerfile that I've been messing with.
# escape=`
FROM microsoft/windowsservercore
SHELL ["powershell", "-command"]
RUN Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression
RUN choco install cygwin -y
RUN refreshenv
RUN [Environment]::SetEnvironmentVariable('Path', $env:Path + ';C:\tools\cygwin\bin', [EnvironmentVariableTarget]::Machine)
I've tried setting the ENTRYPOINT and CMD to try and get into cygwin, but neither seems to do anything. I've also attached to the container with docker run -it and fired off the cygwin command to get into the shell, but it doesn't appear to do anything. I don't get an error, it just returns to the command prompt as if nothing happened.
Is it possible to run another shell in the Windows Container, or am I just doing something incorrectly?
Thanks!
You don't "attach" to a container with docker run: you start a container with it.
In your case, as seen here, docker run -it is the right approach.
You can try as an entry point using c:\cygwin\bin\bash, as seen in this issue.
As commented in issue 32330:
Don't get me wrong, cygwin should work in Docker Windows containers.
But, it's also a little paradoxical that containers were painstakingly wrought into Windows, modeled on containers on Linux, only for people to then want to run Linux-utils in these newly minted Docker Windows containers...
That same issue is still unresolved, with new case seen in May and June 2018:
We have an environment that compiles with Visual Studio but still we want to use git and some very useful commands taken from linux.
Also we use of-the-shelve utilities (e.g. git-repo) that uses linux commands (e.g. curl, grep,...)
Some builds require Cygwin like ICU (a cross-platform Unicode based globalization library), and worst: our builds require building it from source.
You can see an example of a crash in MSYS2-packages issue 1239:
Step 5/5 : RUN "C:\\msys64\\usr\\bin\\ls.exe"
---> Running in 5d7867a1f8da
The command 'cmd /S /C "C:\\msys64\\usr\\bin\\ls.exe"' returned a non-zero code: 3221225794
This can get more information on the crash:
PS C:\msys64\usr\bin>
Get-EventLog -Index 28,29,30 -LogName "Application" | Format-List -Property *
The workaround was:
PS > xcopy /S C:\Git C:\Git_Copy
PS > C:\Git_Copy\usr\bin\sh.exe --version > v.txt
PS > type v.txt
As mentioned in that thread, the output gets lost somewhere in the container, thus sending it to a text file.
After playing with it for a long time, my findings were the following:
If your Cygwin utilities are crashing your container, you need to use process isolation. See https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility for the requirements (essentially you need to use Windows Server 2016 and a build-matching Docker Image). I spent some time trying to understand the reason why hyper-v isolation doesn't work and so far I didn't come to any conclusion;
If your Cygwin utilities apparently do nothing - but they don't crash the container - you need to remove the -t flag (the -i flag is still ok) or alternatively play with stdout redirection. Apparently there seems to be an issue with MSYS2 when it deals with some pseudo-ttys. You can verify that programs still run if you redirect stdout to a file (e.g. whoami won't output anything when you run it without any stdout redirection, but whoami > out.txt will output the expected result to a file). It might be possible to fix this by replacing the pseudo-tty but I didn't try it. I suspect that the problem is an invalid handle somewhere inside the MSYS2 libs - as other console apps can print things to the terminal - but I didn't verify this.
Hope it helps to all of you having the same problem.
I was able to get a preinstalled (copied from the host) copy of Cygwin to work in a nanoserver-based container with these two steps:
Using Żubrówka's recommendation for no -t in the docker run cmd-line (when running docker interactively)
Copying the host's (Windows Server 2016) kernel32.dll to the container's c:\windows\system32
I found serveral versions of kernel32.dll on my system, and used the one from c:\windows\system32 with md5 hash d8948a7af764f7153b3e396ad44992ff
This also made a large variety of other executables work. Note that without a tty, using the container is even more cumbersome, and the bash shell doesn't render the prompt. However, scripts (via Jenkins, in my case) that rely on cygwin components work fine.
If that doesn't help, try this guide, it helped me a lot. If your windows application (other than cygwin) is legitimately missing DLLs, the instructions in this guide can help. It never occurred to me that SysInternals' procmon.exe can be run on the host and still report events from the container!

curl hangs while uploading on Windows

I am using curl on mac and other windows machines to upload my artifacts to HockeyApp service. On one of my machines that runs windows , "curl" constantly "hangs/freezes" during upload.
Here is the command :
curl -F notify=0 -F status=2 -F ipa=#app/build/outputs/apk/app-production-release-2.4.2-SNAPSHOTv42.apk -F dsym=#app/build/outputs/mapping/production/release/mapping.txt -H X-HockeyAppToken:[MY_TOKEN_HERE]https://rink.hockeyapp.net/api/2/apps/[MY_APP_REFERENCE]/app_versions/upload
On windows there is no curl by default , so I use the one installed with this git distribution. I just add the path to curl to path environmental variable. This approach works well on 2 other windows machines. In fact when I open git-bash , the curl command also executes fine. But any attempt to run it from cmd.exe leads to "hanging/freezing".
Any idea on how can I troubleshoot/debug it ?
EDIT :
I have already tried other curl distributions for windows , same result...
I've been struggling with the same issue of curl as well when trying to deploy my app from VSTS to Hockeyapp. in the end I've chosen for not using curl but just using plain powershell on Windows. it's a bit more complicated but it works the same way.
I've uploaded this script to GitHub and can be found there:
https://github.com/Geertvdc/UWPHockeyAppDeployScripts/blob/master/UploadUWPToHockeyApp.ps1
so instead of curl I use Invoke-RestMethod from powershell to do the same call to Hockeyapp.
Try to upgrade your curl to the latest version
where curl
find out where current path of curl, using cywin cli
https://curl.haxx.se/windows/
Come here to find version you want update, download and give it a try.
Reason for this freezing is base on Windows config. I have laptop that need to ghost new installation of Windows 10. Before ghost, curl run well. After ghost, sometime it freezing.
I updated and it runs well now.
Also notice that when run
curl -s
curl will run in silent mode, that never hang out

Resources