Skip to content

[12.x] Improve key:generate error message when APP_KEY is set#58345

Merged
taylorotwell merged 2 commits intolaravel:12.xfrom
dxnter:fix/key-generate-env-error-message
Jan 12, 2026
Merged

[12.x] Improve key:generate error message when APP_KEY is set#58345
taylorotwell merged 2 commits intolaravel:12.xfrom
dxnter:fix/key-generate-env-error-message

Conversation

@dxnter
Copy link
Contributor

@dxnter dxnter commented Jan 11, 2026

When APP_KEY is already set in the environment (e.g., through export APP_KEY=...), running php artisan key:generate fails with a misleading error: "No APP_KEY variable was found in the .env file".

This PR updates the error message to accurately indicate that the environment variable is preventing the update.

I've additionally updated from $this->error() to $this->components->error() to align with other Artisan commands (only DbCommand still uses $this->error()).

Addresses feedback from #58340 (comment)

@taylorotwell taylorotwell merged commit d8c8dc9 into laravel:12.x Jan 12, 2026
70 checks passed
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

Comments