Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Sail commands #29

Closed
MarcEspiard opened this issue Nov 22, 2024 · 11 comments
Closed

Compatibility with Sail commands #29

MarcEspiard opened this issue Nov 22, 2024 · 11 comments

Comments

@MarcEspiard
Copy link

Hey,

It's all in the title!

Great package, would love to be able to use it with sail commands that require to be running within docker, like schedule:work, queue:listen etc..

Still using it for Logs (pail) / Vite in the meantime :)

@aarondfrancis
Copy link
Owner

I'm going to need some more details! What happens if you run sail artisan queue:work outside of Solo and what happens when you run it as a Solo command?

@MarcEspiard
Copy link
Author

Currently nothing happens :)
Running php artisan solo
with this config:
image

The schedule command shows as Stopped and no output is shown:
image

Running the same schedule command just in the terminal shows the usual schedule:work output:
image

Running sail artisan solo (so it runs within docker) and updating the schedule command to php artisan schedule:work (at this point we're inside the docker container so we need to call php as opposed to sail) works, but now the vite command won't work because npm does not exist inside the docker container (you can't run any command against your machine, you're inside the container since solo runs in it).

Ideally we would always run php artisan solo so we stay on the host machine, outside docker, and figure out how to make Sail commands work with solo, so we get the best of both worlds.

Sail uses docker compose exec, that same command translates to running docker compose exec -u sail laravel.test php artisan schedule:work

Hope this helps, let me know if you need more info.

@jesse-s
Copy link

jesse-s commented Nov 22, 2024

vendor/bin/sail artisan schedule:work --ansi works

@aarondfrancis
Copy link
Owner

Ah ok, perfect! Thank you

@MarcEspiard
Copy link
Author

MarcEspiard commented Nov 22, 2024 via email

@aarondfrancis
Copy link
Owner

Good thinking! I'll see what I can do there.

@joshmanders
Copy link

Outside of displaying the error to know whats going on, the reason this happens is because vendor/bin is not in the $PATH. This can be remedied (without users needing to add it to path) by adding it into the environment when Solo starts the process.

This is similarly how npm handles it when you run use a binary installed as a dependency.

@aarondfrancis
Copy link
Owner

Oh huh, I would've just assumed that it inherited the path that existed. Is that not true?

@joshmanders
Copy link

It probably inherits $PATH of the environment running the command, but most people don't have ./vendor/bin in their PATH because it's a local directory, not a global directory.

@MarcEspiard
Copy link
Author

It probably inherits $PATH of the environment running the command, but most people don't have ./vendor/bin in their PATH because it's a local directory, not a global directory.

That's correct, I expect most people to have it as an alias, it's suggested in the Sail docs during the install steps: https://laravel.com/docs/11.x/sail#configuring-a-shell-alias
It is how it's setup on my machines.

@joshmanders
Copy link

It probably inherits $PATH of the environment running the command, but most people don't have ./vendor/bin in their PATH because it's a local directory, not a global directory.

That's correct, I expect most people to have it as an alias, it's suggested in the Sail docs during the install steps: https://laravel.com/docs/11.x/sail#configuring-a-shell-alias It is how it's setup on my machines.

Yup, so it may be beneficial to Solo to add ./vendor/bin into the $PATH env for each command so that way you can just do sail ... inside your command script.

Maybe even add ./node_modules/.bin too so you can quickly utilize npm binaries from your dependencies there too, such as tailwindcss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants