Search code examples
laravelenvoyproxylaravel-sail

Laravel Envoy with Laravel Sail problem - envoy not running


I have a Laravel Sail project, and I am trying to use Envoy to deploy. I followed the guidelines of the Laravel documentation, I installed Envoy, created the Envoy.blade.php file in the root, but when I try to call:

sail envoy run envoy-task

or:

sail vendor/bin/envoy run envoy-task

Docker compose options and commands are listed, and envoy does not start at all. Why is this happening?

I tried to find solution from everywhere, but no success.


Solution

  • This is a fairly quick fix luckily, sail has a limited list of commands that it can run directly.

    You can see what they are by looking inside vendor/bin/sail (it's a text file) or just running ./vendor/bin/sail directly. Laravel have added many, such as up, down, artisan, test, shell, composer, npm, and so on.

    If the command is not supported by sail, it will pipe it through to the docker-compose command.

    In this case the envoy and vendor/bin/envoy commands you tried to run are not valid docker-compose commands, so instead it fails and shows you the full list of Docker Compose commands.

    Workaround

    Try this instead:

    sail exec laravel.test php vendor/bin/envoy run envoy-task
    

    This will exec (run/execute) the command inside one of your containers (typically named laravel.test but you may have changed this in your docker-compose.yml).

    The command itself is php vendor/bin/envoy run envoy-task.

    The format is: sail exec <service> <command>

    Simplification

    If you find you need to run a lot of envoy commands inside sail and the above command is too long, you can create a ./envoy bash script with something like this:

    vendor/bin/sail exec laravel.test php vendor/bin/envoy run "${@:1}"
    

    Then it should be as simple as running: ./envoy envoy-task which will run envoy-task inside your container.