vscode-laravel-pint icon indicating copy to clipboard operation
vscode-laravel-pint copied to clipboard

Latest version is not working with sail enabled

Open Alph44rchitect opened this issue 2 years ago • 13 comments
trafficstars

Describe the bug The latest extension version is not working with Laravel Sail setting enabled. It seems to be ignored.

To Reproduce Steps to reproduce the behavior:

  1. Install Laravel sail
  2. Install latest version of the extension
  3. Set enableDebugLogs: true
  4. Set runInLaravelSail: true
  5. Run format command
  6. Watch the output log and see that is still using the non sail path

Expected behavior Using the sail path to run pint.

Environment:

  • Operating system: Ubuntu 22.04 via Windows with WSL2
  • IDE / version: VSCode / latest
  • Extension version: 1.1.4
  • Extension's config: enableDebugLogs: true, runInLaravelSail: true

Additional context The version 0.7.3 works as expected.

Alph44rchitect avatar Jan 08 '23 14:01 Alph44rchitect

Thanks for raising the issue!

Will take a look at this

d8vjork avatar Jan 14 '23 12:01 d8vjork

+1 on this issue

benjamindonze avatar Feb 21 '23 17:02 benjamindonze

Sorry to say but this feature cannot be viable, as VSCode doesn't provide same Bash/Zsh/shell context with it so doesn't know where Docker is or any other binary, for global Pint this uses a predefined path setting, but Sail needs Docker therefore need to be on the PATH, the one we can't have access to from an child process from the VSCode one (unless some special things applied to this one).

Anyway will continue on the research of this and add help wanted

d8vjork avatar Feb 22 '23 14:02 d8vjork

@d8vjork have you considered something like this?

docker-compose exec -T laravel.test ./vendor/bin/pint

This executes the command inside the default app container that comes with Sail and logs the output to terminal. Should be executable from the shell context of VSCode and its extensions (works fine for me locally anyway.)

GringoDotDev avatar Feb 23 '23 18:02 GringoDotDev

@jseitel Problem with that still the same, need to find out where is that docker-compose (or in case of newer versions, docker compose), could be specified on an extension setting tho

d8vjork avatar Feb 24 '23 23:02 d8vjork

@d8vjork I haven't looked into the details but it was working as expected with v0.7.3 and still is. What changed?

Alph44rchitect avatar Mar 09 '23 18:03 Alph44rchitect

@d8vjork I haven't looked into the details but it was working as expected with v0.7.3 and still is? What changed?

You are actually right... after checking 0.7.x I discovered that I was actually wrapping the execution into a VSCode Task, will try if I could achieve the same on this new refactor I did on v1

Note to myself: Use ShellExecution from VSCode API to wrap the command

d8vjork avatar Mar 09 '23 21:03 d8vjork

Laravel pint vscode, still isn't working with docker/sail, is there any development on this ? Is there any workaround?

ricardosoares09 avatar Mar 10 '24 19:03 ricardosoares09

Laravel pint vscode, still isn't working with docker/sail, is there any development on this ? Is there any workaround?

use 0.7.3

astral-data avatar Mar 29 '24 02:03 astral-data

I encountered a similar issue with the latest version of the Laravel Pint VSCode extension not working correctly in a Laravel Sail setup. After some troubleshooting, I found a solution that worked for me, especially if you're working in a .devcontainer environment.

My Solution:

If you're using a .devcontainer environment, add the following snippet to your devcontainer.json settings and rebuild the container:

"settings": {
                "laravel-pint.enable": true,
                "laravel-pint.executablePath": "vendor/laravel/pint/builds/pint",
                "[php]": {
                    "editor.defaultFormatter": "open-southeners.laravel-pint",
                    "editor.formatOnSave": true
                }
            }

The Problem:

It seems that the default path for Laravel Pint (vendor/bin/pint) has been moved in the latest Laravel Sail installation, likely to vendor/laravel/pint/builds/pint.

Alternative Solution:

If you're not using a .devcontainer environment, you could try changing the executablePath in your workspace or extension config to match the new path.

I hope this helps anyone else encountering the same issue!

GabrielDSousa avatar Sep 20 '24 15:09 GabrielDSousa

Just to report, I have same issue! Waiting for new version, but using version 0.7.3 as commented above

csouza1995 avatar Oct 15 '24 19:10 csouza1995