Laravel Build Error on Composer Install (Related to APP_URL?)

I just tried to deploy a fresh Laravel project running Statamic CMS. I got a weird build error:

In Request.php line 321: Symfony\Component\HttpFoundation\Request::create(): Argument #1 ($uri) must be of type string, null given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/SetRequestForConsole.php on line 31

At the end of the composer install step. According to a quick search this is usually caused by not having an APP_URL set in the ENV file. However I have it set in my fly.toml, here are all my “[env]” entries:

  APP_URL = ""
  APP_ENV = "production"
  LOG_CHANNEL = "stderr"
  LOG_LEVEL = "info"
  LOG_STDERR_FORMATTER = "Monolog\\Formatter\\JsonFormatter"
  CP_ENABLED = false

Any ideas on how to fix this?


Ah. I would guess that (like secrets) those variables are only available to your app/vm at run-time. Not at build-time, which you mention. A subtle difference. So at that moment, your APP_URL would not be set, explaining the null error.

Since an APP_URL is not a secret, the simplest fix may be to just hard-code that into your Dockerfile. Then it must be available at build-time. Not sure if using ENV or ARG is better but e.g:


Can’t hurt to try. See what happens next time you build/deploy :slightly_smiling_face:

That’s good it works.

As for why that’s not in the default Dockerfile, I would guess that shouldn’t (or at least didn’t used to) be needed for a default Laravel installation at build-time.

I’d guess (having not tried it) it could be due to the addition of Statamic :thinking:? As I recall the base guide is just for a hello-world style Laravel site.

And yep, setting it to anything would work as that error message is complaining it’s null. Setting it to a string, any string, would thus bypass that error.

I’ve been playing with statamic and haven’t seen that error - Is there something to adjust?

If so, I’m happy to do it!