Fixing composer config http-basic... is not defined in GitLab CI #11238
Replies: 3 comments 6 replies
-
The same issue here but with another Versioning/CI/CD platform - GitHub. We should fix that. |
Beta Was this translation helpful? Give feedback.
-
As there is no quotes around the bash variable, if that variable is empty (due to not being defined), the command being run will be There is no way composer can warn you here. the command being run is a valid one, but for a different use case than your own. composer config http-basic.nova.laravel.com "${NOVA_USERNAME}" "${NOVA_PASSWORD}" With this command instead, the command being run when the variables are empty/undefined will be |
Beta Was this translation helpful? Give feedback.
-
Instead of running a command in your CI job, you can set the |
Beta Was this translation helpful? Give feedback.
-
I'm using Laravel Nova. Since it's distributed under a commercial license, it requires auth during installation, and their docs show how to do this using the
http-basic
option in composer to allow it to run in my gitlab.com CI.This all works fine in PHP 8.1, however, after updating the CI environment to PHP 8.2 and composer 2.5, it fails:
I was mystified by this because all else had remained unchanged.
This command defines the
http-basic.nova.laravel.com
property, so complaining that it's not defined seems nonsensical. However, if the variables are not defined at all, they won't appear in the command, and it will effectively become:which is asking for a config value rather than setting one, and this explains the error. But why would these vars not be set when they were working fine before?
So I went and checked the config in GitLab, and noticed that I had originally marked these env vars as
protected
, which in GitLab means that these variables are only set for branches that are also protected. But I had created a new branch for testing PHP 8.2, which was not protected, so would not receive these variables.Either unprotecting the vars or protecting the branch that's running in CI solves the problem.
So if you see error this in GitLab CI, check your env var visibility or branch protection state.
Beta Was this translation helpful? Give feedback.
All reactions