[FIXED] Unable to set the APP_PORT on .env for Laravel Sail

Issue

I have the following problem in Windows 10 (in Ubuntu works properly):

I’m working in Laravel 8 with Sail
When I create the APP_PORT variable on .env

APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_PORT=3000

…and launch the web with sail up I get this error:

services.laravel.test.ports contains an invalid type, it should be a number, or an object

This is how the docker-compose.yml looks

    version: '3'
    services:
        laravel.test:
            build:
                context: ./docker/8.0
                dockerfile: Dockerfile
                args:
                    WWWGROUP: '${WWWGROUP}'
            image: sail-8.0/app
            ports:
                - '${APP_PORT:-80}:80'
...

I know that I could just put ports: - '3000:80' but since I’m working in team and the php artisan sail:install command will overwrite the docker-compose.yml file I don’t wanna change the docker-compose.yml file.

Thanks in advance.

Solution

The solution for Laravel Sail (Docker) on Windows 10 was changing the .env EOL from CRLF to LF. I found it out because I was trying to resolve this warnings from another issue:

./.env: line X: $'\r': command not found
/usr/bin/env: bash: No such file or directory

After I resolved that EOL conflict the sail up command was able to read all the enviroment variables. I also changed the EOL to LR in the following files:

.env
artisan
docker/7.4/start-container
docker/8.0/start-container
vendor/laravel/sail/runtimes/8.0/start-container
vendor/laravel/sail/runtimes/7.4/start-container

It’s clear why this problem wasnt present on Ubuntu.

Answered By – Fredy Rosero

Answer Checked By – Gilberto Lyons (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published