Composer install requirements (without a lock file) #10013
Replies: 2 comments 4 replies
-
this isn't facepalm
this is See https://blog.engineyard.com/composer-its-all-about-the-lock-file for a good explanation.
What would that flag be named? You have to use Composer knowing what you are doing, not trying commands until they work. You know if you have |
Beta Was this translation helpful? Give feedback.
-
I don't think we really want to spend much effort optimizing this case away, as it's fairly special, and frankly quite rare that you'd find a PHP requirement that cannot be fulfilled in the root package. Any other requirement than platform ones we can't really do a fast fail we'd have to load all packages to know if it can be resolved. What I wonder though is whether you are using Composer 1 or 2, because it seems to me like v2 should ideally not kill a t2.small instance.. But that definitely depends a lot on your project's composer.json and dependency graph. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Doing this as a discussion as I hit some problems that are clearly more my issue then composers, but wanted to share in case it is felt it might be worth resolving somewhat within this project.
Story is I tried installing a repo that git ignored composer.lock (I know 🤦🏼 ). This ended up locking up the CPU of an aws t2.small instance for long enough (5+ mins) that I gave up and rebooted it. It didn't even get to listing out the depencies for download, just warned there was no lock file then got stuck after
Loading composer repositories with package information. Updating dependencies
.Tried it on a local clone and had to run with
memory_limit=-1
as it hit a memory exception, before eventually it told me it couldn't resolve as it needs php7 and I was using php8. (The server also uses php8, so would presumably eventually have stopped in the same way had I let it continue)I appreciate this is best solved by A) Always include the lock file B) install with the right PHP version. However it does feel like something is a bit off here from what I'd expect to happen in this foolish scenario.
The composer.json has:
Is it as intended that it may need "significant" memory / cpu to realise that top level php requirement isn't met? I assuming it's recursively checking all the packages so as to give a full list of all problems (and one is probably very heavy here), but if the root composer.json isn't met is there really an advantage in continuing? IDK if a fast-fail would matter for many other root options, but it feels kinda weird that it needs to do a big process even if the basic php concern isn't fulfilled.
More generically are the requirements for running
composer install
with no lock such that you would never recommend running install without the lock file on a server? Or does this vary so much with the packages / server specs there's not a clear answer?Currently I can see no "safe" way to install only from a lock file - if there's no .lock it will warn you, but then it immediately starts the more expensive process of generating one anyway. Handy on local; but not great on a smaller server. Would you consider having a flag, or alternative install command that just stops if there's no lock file to work from?
Beta Was this translation helpful? Give feedback.
All reactions