Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

censin's avatar

Laravel Sail commands not working on existing project, but docker compose is

I have a project that I am running locally with Laravel Sail. I am trying to give my configuration to my team so that we can all share the same configuration. To test this process I started with a fresh machine (macOS) and got docker and composer running. I cloned the repository and composer installed to get the sail binary.

I've aliased ./vendor/bin/sail to sail. At this point running sail up -d I get a spam of 12 instances of : command not found followed by 1 error(s) decoding:

Additionally, if I add an APP_PORT entry to my .env, such as APP_PORT=60000, I end up getting these errors:

* error decoding 'ports': Invalid hostPort: 60000
1 error(s) decoding:

* error decoding 'ports': Invalid hostPort: 60000

Sail will continue IF I don't have an APP_PORT set in my .env after the "command not found" spam. However, I need to be able to set the APP_PORT due to multiple projects conflicting otherwise.

So far, I have tried installing multiple versions of sail ranging from 1.18.0 to 1.25.0 and all have had this issue. I have reproduced this on two machines, an Mac with M2 chip and another with an intel chip.

I have had success with using docker compose directly by doing docker-compose up -d instead of using sail.

I've used sail for over a year and never had these types of issues, especially nothing with such sparse errors. I'd appreciate any direction or ideas if anyone has any.

0 likes
2 replies
censin's avatar

I believe that I found the culprit. It seems to be the format of my .env file. I recreated it by copying my .env.example and renaming it .env and it's working fine. The new file and the old file have the same permissions and content, I'm unsure what other differences between the two files could exist but clearly there is something there.

The issue is solved, but if anyone has any thoughts on why creating my .env via touch or creating a new file through my text editor created this problem I'd be interested to know.

tpra7's avatar

@censin I've had almost the exact same problem after manually upgrading a huge project from laravel 6 to 7 to 8 to 9 (yes...), so i basically did a lot of copy/paste from the github comparison tool while following the upgrade guides.

  • spam of 12 instances of ":command not found" on almost any sail command
  • though no "error(s) decoding" like you had
  • mac m2

Solved with the exact weird method you mentionned (many thanks!) :

  • I downloaded a fresh .env.example from laravel github, made the changes for my project and voilà, no more error messages

Very hard to identify, without your post i would never have found a solution. Many thanks again.

In almost 25 years of programming i've had bugs very similar to this problem maybe 3 or 4 times, always after copy/pasting from elsewhere to the file i'm working on. I only have seen it in JS (result has always been a completly non-working script), first time ever in another situation.

Please or to participate in this conversation.