New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: --is-install-needed #3888
Comments
This might allow for effective caching on Travis, because it wouldn't regenerate the autoload.php every time. Tho, something like
might be nicer |
Ok, the first problem is the autoload dumping. That leaves the second problem (the feature request): you still have to grep, because there is no direct Composer command. What about changing the default behavior of |
@jakoch RE adding the However that still requires that we grep the output of composer to determine if install needs to be run or not. And as recently as 4-6 weeks ago, composer moved all output from STDOUT to STDERR, and so it effectively broke all code that was trying to grep. (That is why this became an issue). Furthermore, composer SHOULD be able to change its output style or content whenever it wants. No code should ever expect it to output in a certain format. But for that to work, we need a way to get info like "does install need to be run" without having to grep for output. Thus I maintain that some switch like
While I agree with you that it seems odd for composer to update the autoload file even when it hasn't made any changes, for all I know the purpose of I fear that to change the existing behavior would break any automated workflows that rely on Here again, the |
@fprochazka I like the |
Perhaps the better solution would be to atomically rewrite autoload.php or not rewrite it if it hasn't changed |
@carnage while atomic file writes are never a bad thing, I disagree that it would be a better solution to do that instead of adding a switch. Any time you write the file, you are wasting CPU and I/O on the production system. Once, to write the file. And more importantly, again because you have invalidated the opcode cache and so during a production run of the software it needs to recompute that cache. That's just silly since the contents of the file have not changed at all. So +1 for the idea of atomic file writes, but that could be done in addition to the adding of a flag like |
@Seldaek Any thoughts on this issue? It boils down to this: Do you force apps to grep your output, and then react every time you change it (as you have done recently, and likely will again), or do you add a new switch of your choice to facilitate automation? |
@ross-p if we are wanting to support automation better, a git style --porcelain flag for all commands (or a relevent subset) might be best, this gives an output which is suitable for machine parsing. Atomic file writes should probably be a separate feature request |
Just passing by... Carnage, i think you are spot on with the |
Note that |
In regards to the Isn't the The output changes were to be more "unixy" I believe, to allow for output to be grepped. The Would it be less "unixy" to non-zero exit on a dry-run if it needed to do something to complete an install? |
@carnage @jakoch you guys are right, machine-formatted output would be a valid alternate solution to this problem. @stof The reason this came up is to ensure that |
@slbmeh no it would not. A dry-run telling you that something will be done is not an error IMO. An error would be a dry-run telling you that deps cannot be resolved anymore. |
@slbmeh - re "porcelain": what you said is indeed the main distinction, but it seems some git commands still have such params -
Vagrant has Their main point being that they're BC-friendly. |
IMO this is just too fringe use case, so that using grep is ok. |
It's terribly difficult to reliably determine in a programmatic manner if
composer install
actually needs to be executed.AFAICT the only way is to parse output. And yet composer just changed it so that nothing gets written to stdout, it all goes to stderr instead. And thus is perfectly illustrated a reason why parsing output is a terrible way to do anything that should be automated.
Thus I request a feature
composer --is-install-needed
which can be used thus:The problem right now is that
--optimize-autoloader
, which should always be used in production, always rewrites theautoload.php
, which essentially causes potential downtime every time you runcomposer install
, even if nothing was actually changed.There exists
composer --dry-run
but this is not adequate for programmatic interpretation of whether or not something will actually be done, particularly given the recent history of composer changing its output in backwards-incompatible ways.The text was updated successfully, but these errors were encountered: