Fix: Allow postCreateCommand to fail silently in VS Code on Windows #626
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is an issue for Windows users when using Dev Containers from VS Code. This issue will not be seen by Linux users.
When a Laravel project is created with the curl command which includes the
&devcontainer
option, similar to this:curl -s "https://laravel.build/my-project-name?with=mysql,redis,meilisearch,mailpit,selenium&devcontainer" | bash
The file
devcontainer.json
includes the following line:"postCreateCommand": "chown -R 1000:1000 /var/www/html"
As the files that are created inside a container (by VS Code) are automatically created as though the owner is
root
(due to complications with drives/folders mapped from Windows to a Linux container), the line above will fail to change the permissions of the files beneath/var/www/html
. Finally the command will conclude with an error due to a non-zero return code.Not only does this worry the user into thinking that there has been a serious error (when actually the error can be ignored), if the user adds any further postCreateCommands, they will fail to execute.
The resolution I have applied is to supress the output from the
chown
command and to force it to return 0 (non-error). This will make the output look clean and will allow any further postCreateCommands to proceed.The other option is to delete the line for Windows users, but it is better if the line is common between different OS's.
The down side is that if there is a real error when running the line on non-Windows machines, the user will not see the error reported.