Skip to content

Fix read non existing config file#1398

Merged
mattstauffer merged 1 commit intolaravel:masterfrom
mischabraam:hotfix/read-non-existing-config-file
Apr 26, 2023
Merged

Fix read non existing config file#1398
mattstauffer merged 1 commit intolaravel:masterfrom
mischabraam:hotfix/read-non-existing-config-file

Conversation

@mischabraam
Copy link
Copy Markdown
Contributor

@mischabraam mischabraam commented Apr 4, 2023

When composer installing valet, the config.json does not exist yet. If we do a status check like valet status, the non existing config file is read. Which throws an error/warning.

.. % ./valet status
Checking status...
PHP Warning:  file_get_contents(/Users/someone/.config/valet/config.json): Failed to open stream: No such file or directory in /Users/someone/Development/Tools/valet/cli/Valet/Filesystem.php on line 84

Warning: file_get_contents(/Users/someone/.config/valet/config.json): Failed to open stream: No such file or directory in /Users/someone/Development/Tools/valet/cli/Valet/Filesystem.php on line 84

Valet status: Error

+------------------------------------------+----------+
| Check                                    | Success? |
+------------------------------------------+----------+
| Is Valet fully installed?                | No       |
| Is Valet config valid?                   | No       |
| Is Homebrew installed?                   | Yes      |
| Is DnsMasq installed?                    | Yes      |
| Is Dnsmasq running?                      | Yes      |
| Is Dnsmasq running as root?              | Yes      |
| Is Nginx installed?                      | Yes      |
| Is Nginx running?                        | Yes      |
| Is Nginx running as root?                | Yes      |
| Is PHP installed?                        | Yes      |
| Is linked PHP (php@8.1) running?         | Yes      |
| Is linked PHP (php@8.1) running as root? | Yes      |
| Is valet.sock present?                   | No       |
+------------------------------------------+----------+

Debug suggestions:
Run `composer require laravel/valet` and `valet install`.
Run `valet install` to update your configuration.
Run `valet install`.

To fix this we can first check the file of its existence before reading it.

@mattstauffer mattstauffer merged commit dae5773 into laravel:master Apr 26, 2023
@mischabraam mischabraam deleted the hotfix/read-non-existing-config-file branch April 28, 2023 07:32
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

Successfully merging this pull request may close these issues.

2 participants