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

Errors with WSL2 containers #112

Open
jd4u opened this issue Apr 28, 2024 · 7 comments
Open

Errors with WSL2 containers #112

jd4u opened this issue Apr 28, 2024 · 7 comments

Comments

@jd4u
Copy link

jd4u commented Apr 28, 2024

Intellisense stops working after giving errors every few seconds.

The container name "dev-laravel.test-1" is wrong.

"Laravel Extra Intellisense" is calculated container name based on local development. Using WSL2, the local folder was soft-linked with different name - "lirt". So the sail created container with name "lirt-laravel.test-1".

Suggestion: While using remote workspace, use the remote directory name instead of local directory name as prefix for container name calculation.

Request: Please release this change in next update soon. I see many related errors. The suggestion implementation will solve few of them.

Local Path: D:\lirt\dev\
WSL2 Path: /home/jd/lirt/

image

@jd4u
Copy link
Author

jd4u commented Apr 28, 2024

Workaround for above issue: keep local and wsl2 folders having same names.

Another issue: After renaming my local folder from "dev" to "lirt" the above error is gone. Though now the new error is coming multiple times every seconds... "Do not show this" button was clicked to avoid error alert, but in output window, the error is continuous...

PHP Parse error:  Unclosed '(' in Command line code on line 1

image

Please suggest....

@amir9480
Copy link
Owner

amir9480 commented May 23, 2024

@jd4u

The extension does nothing to WSL or docker, It simply runs a command and gets JSON data from your project in the stdout.

You may change the default configuration to work on your project:

https://github.com/amir9480/vscode-laravel-extra-intellisense#laravelextraintellisensebasepath

https://github.com/amir9480/vscode-laravel-extra-intellisense#sample-config-to-use-docker

@jd4u
Copy link
Author

jd4u commented May 25, 2024

Using sample config to use docker, I configured following.

In 'Remote' settings
- "LaravelExtraIntellisense.basePathForCode": "/home/jd/lirt"
- "LaravelExtraIntellisense.phpCommand": "docker-compose exec -w /home/jd/lirt laravel.test php -r \"{code}\""
also tried following
- "LaravelExtraIntellisense.phpCommand": "sail php -r \"{code}\"" 

But the errors are persistent...
image

Using second phpCommand should work...!! but gives error..
image

@amir9480
Copy link
Owner

@jd4u
Look like you are using the host directory instead of the container directory.
For Sail it should be something like this:

"LaravelExtraIntellisense.basePathForCode": "/var/www/html",
"LaravelExtraIntellisense.phpCommand": "docker-compose exec -w /var/www/html laravel.test php -r \"{code}\""

@jd4u
Copy link
Author

jd4u commented May 26, 2024

@amir9480 , I appreciate your guidance...

Even after using container directory, error persists...

2024-05-26 20:52:53.904 [info] Laravel Extra Intellisense command started: Application Models
2024-05-26 20:52:53.904 [info] Laravel Extra Intellisense command started: Auth Data
2024-05-26 20:52:53.904 [error] Laravel Extra Intellisense Error:
 Application Models

/bin/sh: 1: Syntax error: "(" unexpected

2024-05-26 20:52:53.905 [error] Laravel Extra Intellisense Error:
 Auth Data

/bin/sh: 1: Syntax error: "(" unexpected

@jd4u
Copy link
Author

jd4u commented May 26, 2024

The setup of configs is in "Remote" settings tab. User and Workspace are kept as is...

@maaarghk
Copy link

I resolved this error in my particular setup, docker compose + linux. My config contains:

"LaravelExtraIntellisense.phpCommand": "/local/path/to/project/bin/php -r \"{code}\""

where bin/php is a shell script which contains:

#!/bin/sh
docker compose exec -w /container/path/to/project -u 1000 php-fpm php $@

The fix was to change the shell script to this:

#!/bin/sh
docker compose exec -w /container/path/to/project -u 1000 php-fpm php "$@"

i.e.: ensure that the arguments passed to the php-in-docker wrapper remain quoted in the same way when passed on.

@jd4u notice in your last two examples the error is coming from sh and not PHP, so something else is weird there. Is vscode itself running commands inside a container already? For me, where I am not using any vs code container integration and just managing docker compose myself manually, the following config works well:

    "LaravelExtraIntellisense.phpCommand": "docker compose exec -w /container/path/to/project -u 1000 php-fpm php -r \"{code}\"",

I think that is exactly what was proposed by @amir9480 above.

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

3 participants