Skip to content
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

symfony recipes : composer recipes vs composer help "recipes" #10147

Closed
Jduret opened this issue Oct 11, 2021 · 4 comments
Closed

symfony recipes : composer recipes vs composer help "recipes" #10147

Jduret opened this issue Oct 11, 2021 · 4 comments
Labels
Milestone

Comments

@Jduret
Copy link
Contributor

Jduret commented Oct 11, 2021

I'm trying to use your composer Docker image. My project use Symfony and the Symfony/Flex Composer extension.
I use a shortcut to run composer command :

#/usr/local/bin/composer
sudo docker run --rm --interactive --tty \
--volume $PWD:/app \
--volume ${COMPOSER_HOME:-$HOME/.composer}:/tmp \
composer "$@"

My issue occured when I try to call composer recipes under my project.

/docker-entrypoint.sh: exec: line 24: recipes: not found

So I open a bash in the container.

docker run -it --volume $PWD:/app \
--entrypoint /bin/bash composer

And then I ran the command : composer recipes

 bash-5.1# composer recipes

 Available recipes.

 * doctrine/annotations
  * doctrine/doctrine-bundle (update available)
 * doctrine/doctrine-migrations-bundle (update available)
 * symfony/apache-pack (update available)
 * symfony/console (update available)
 * symfony/flex
 * symfony/framework-bundle (update available)
 * symfony/maker-bundle
 * symfony/monolog-bundle (update available)
 * symfony/phpunit-bridge (update available)
 * symfony/routing (update available)
 * symfony/twig-bundle (update available)
 * symfony/validator (update available)
 * symfony/web-profiler-bundle

Run:
 * composer recipes vendor/package to see details about a recipe.
 * composer recipes:install vendor/package --force -v to update that recipe.

So the error is not from composer but from the entrypoint.
In the entrypoint I found this :

isCommand() {
  # Retain backwards compatibility with common CI providers,
  # see: https://github.com/composer/docker/issues/107
  if [ "$1" = "sh" ]; then
    return 1
  fi

  composer help "$1" > /dev/null 2>&1
}

So I ran this command : composer help "recipes"

bash-5.1# composer help "recipes"

  [Symfony\Component\Console\Exception\CommandNotFoundException]
  Command "recipes" is not defined.

help [--xml] [--format FORMAT] [--raw] [--] [<command_name>]

Can you explain me why composer recipes work and composer help "recipes" don't ?

I've already tried the commande composer help "recipes" using a local composer and it works

@alcohol
Copy link
Member

alcohol commented Oct 11, 2021

I think it is because those commands are added at runtime. Perhaps the help command cannot resolve them due to this. Running composer help recipes does not work for me even from inside the container (where it calls composer directly). Which is peculiar because composer list does list it as an available command. @Seldaek any idea why?

@Seldaek
Copy link
Member

Seldaek commented Oct 11, 2021

Oh yeah, we did optimize these away by default, forgot to also add to help. This has nothing to do with docker.

@Seldaek Seldaek transferred this issue from composer/docker Oct 11, 2021
@Seldaek
Copy link
Member

Seldaek commented Oct 11, 2021

Related/similar to #10075

@Seldaek Seldaek added the Bug label Oct 11, 2021
@Seldaek Seldaek added this to the 2.1 milestone Oct 11, 2021
@alcohol
Copy link
Member

alcohol commented Oct 11, 2021

No idea if relevant or related as well, but running composer list symfony lists several commands from the symfony namespace, but running composer list recipes fails:

Fatal error: Uncaught ValueError: max(): Argument #1 ($value) must contain at least one element in phar:///usr/bin/composer/vendor/symfony/console/Descriptor/TextDescriptor.php:277
Stack trace:
#0 phar:///usr/bin/composer/vendor/symfony/console/Descriptor/TextDescriptor.php(277): max(Array)
#1 phar:///usr/bin/composer/vendor/symfony/console/Descriptor/TextDescriptor.php(194): Symfony\Component\Console\Descriptor\TextDescriptor->getColumnWidth(Array)
#2 phar:///usr/bin/composer/vendor/symfony/console/Descriptor/Descriptor.php(55): Symfony\Component\Console\Descriptor\TextDescriptor->describeApplication(Object(Composer\Console\Application), Array)
#3 phar:///usr/bin/composer/vendor/symfony/console/Helper/DescriptorHelper.php(69): Symfony\Component\Console\Descriptor\Descriptor->describe(Object(Symfony\Component\Console\Output\ConsoleOutput), Object(Composer\Console\Application), Array)
#4 phar:///usr/bin/composer/vendor/symfony/console/Command/ListCommand.php(81): Symfony\Component\Console\Helper\DescriptorHelper->describe(Object(Symfony\Component\Console\Output\ConsoleOutput), Object(Composer\Console\Application), Array)
#5 phar:///usr/bin/composer/vendor/symfony/console/Command/Command.php(245): Symfony\Component\Console\Command\ListCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 phar:///usr/bin/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 phar:///usr/bin/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Symfony\Component\Console\Command\ListCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 phar:///usr/bin/composer/src/Composer/Console/Application.php(327): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 phar:///usr/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 phar:///usr/bin/composer/src/Composer/Console/Application.php(128): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 phar:///usr/bin/composer/bin/composer(67): Composer\Console\Application->run()
#12 /usr/bin/composer(29): require('phar:///usr/bin...')
#13 {main}
  thrown in phar:///usr/bin/composer/vendor/symfony/console/Descriptor/TextDescriptor.php on line 277

Edit: looks like it fails in symfony vendor code though; so perhaps not an issue we can address.

Jduret pushed a commit to Jduret/composer that referenced this issue Oct 12, 2021
- Add 'help' in the list of commands that need plugin command ($mayNeedPluginCommand)
- Remove `'global' !== $commandName` because $mayNeedPluginCommand encure that $commandName is one of `false`, `empty`, `list` or `help` (so never 'global')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants