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

Install fails with a missing class #252

Open
omnicolor opened this issue Jul 18, 2024 · 7 comments
Open

Install fails with a missing class #252

omnicolor opened this issue Jul 18, 2024 · 7 comments
Assignees

Comments

@omnicolor
Copy link

omnicolor commented Jul 18, 2024

With a brand new repository, trying to run ./vendor/bin/captainhook install fails with a missing class if you haven't done the configure step:

mordor captainhook-test(000 main) /$ composer require --dev captainhook/captainhook-phar
./composer.json has been updated
Running composer update captainhook/captainhook-phar
Loading composer repositories with package information
Updating dependencies
Lock file operations: 5 installs, 0 updates, 0 removals
  - Locking captainhook/captainhook-phar (5.23.3)
  - Locking phar-io/composer-distributor (1.0.2)
  - Locking phar-io/executor (1.0.1)
  - Locking phar-io/filesystem (2.0.1)
  - Locking phar-io/gnupg (1.0.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 5 installs, 0 updates, 0 removals
  - Installing phar-io/filesystem (2.0.1): Extracting archive
  - Installing phar-io/executor (1.0.1): Extracting archive
  - Installing phar-io/gnupg (1.0.2): Extracting archive
  - Installing phar-io/composer-distributor (1.0.2): Extracting archive
captainhook/captainhook-phar contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
Do you trust "captainhook/captainhook-phar" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?] y
  - Installing captainhook/captainhook-phar (5.23.3): Extracting archive
  - Downloading artifact from https://github.com/captainhookphp/captainhook/releases/download/5.23.3/captainhook.phar
  - PHAR signature successfully verified
Generating autoload files
2 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found.
Using version ^5.23 for captainhook/captainhook-phar
mordor captainhook-test(200 main) /$ ./vendor/bin/captainhook install

PHP Fatal error:  Uncaught Error: Class "Normalizer" not found in phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/vendor/symfony/string/AbstractUnicodeString.php:29
Stack trace:
#0 phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/vendor/symfony/console/Helper/Helper.php(45): [constant expression]()
#1 phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/vendor/symfony/console/Application.php(706): CaptainHook\Phar\Symfony\Component\Console\Helper\Helper::width()
#2 phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/vendor/symfony/console/Application.php(679): CaptainHook\Phar\Symfony\Component\Console\Application->doRenderThrowable()
#3 phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/vendor/symfony/console/Application.php(142): CaptainHook\Phar\Symfony\Component\Console\Application->renderThrowable()
#4 phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/vendor/symfony/console/Application.php(162): CaptainHook\Phar\Symfony\Component\Console\Application->CaptainHook\Phar\Symfony\Component\Console\{closure}()
#5 phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/bin/captainhook(63): CaptainHook\Phar\Symfony\Component\Console\Application->run()
#6 phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/bin/captainhook(64): CaptainHook\Phar\{closure}()
#7 /home/omni/code/captainhook-test/vendor/bin/captainhook(17): require('...')
#8 {main}
  thrown in phar:///home/omni/code/captainhook-test/vendor/bin/captainhook/vendor/symfony/string/AbstractUnicodeString.php on line 29

Using the non-.phar version tells the user to create the configuration file instead of dying.

@sebastianfeldmann sebastianfeldmann self-assigned this Jul 18, 2024
@sebastianfeldmann
Copy link
Collaborator

What PHP version are you running?

@omnicolor
Copy link
Author

$ php -v
PHP 8.3.9 (cli) (built: Jul  5 2024 12:03:46) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.9, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans

@sebastianfeldmann
Copy link
Collaborator

Could you run php --info | grep intl and check if your php is compiled with '--enable-intl'

or you see lines like

intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => Off => Off

@sebastianfeldmann
Copy link
Collaborator

sebastianfeldmann commented Jul 18, 2024

My guess is, that your PHP comes without INTL extension and then the Symphony intl-polyfill should kick in. But since all Symfony classes get scoped the Normalizer gets scoped as well to Captainhook\Phar\Normalizer so the class Normalizer can't be found.

If you can confirm you do not have the intl extension I will try to figure out how I can solve the problem.

@omnicolor
Copy link
Author

Yes, you're correct, my PHP doesn't have the intl extension.

@sebastianfeldmann
Copy link
Collaborator

Can you give the PHAR file from this beta release page a try?
https://github.com/captainhookphp/captainhook/releases/tag/5.23.4-beta

@omnicolor
Copy link
Author

I'm not sure what's going on now, but the link on that release page seems a bit weird, showing the same version I got with composer require --dev captainhook/captainhook-phar:

$ wget --quiet https://github.com/captainhookphp/captainhook/releases/download/5.23.4-beta/captainhook.phar
$ php ./captainhook.phar --version
CaptainHook version 5.23.3 2024-07-07 #StandWithUkraine
$ ./vendor/bin/captainhook --version
CaptainHook version 5.23.3 2024-07-07 #StandWithUkraine
$ php ./captainhook.phar install

PHP Fatal error:  Uncaught Error: Class "Normalizer" not found in phar:///home/omni/code/slack/captainhook.phar/vendor/symfony/string/AbstractUnicodeString.php:29
Stack trace:
#0 phar:///home/omni/code/slack/captainhook.phar/vendor/symfony/console/Helper/Helper.php(57): [constant expression]()
#1 phar:///home/omni/code/slack/captainhook.phar/vendor/symfony/console/Application.php(731): CaptainHook\Phar\Symfony\Component\Console\Helper\Helper::width()
#2 phar:///home/omni/code/slack/captainhook.phar/vendor/symfony/console/Application.php(704): CaptainHook\Phar\Symfony\Component\Console\Application->doRenderThrowable()
#3 phar:///home/omni/code/slack/captainhook.phar/vendor/symfony/console/Application.php(142): CaptainHook\Phar\Symfony\Component\Console\Application->renderThrowable()
#4 phar:///home/omni/code/slack/captainhook.phar/vendor/symfony/console/Application.php(162): CaptainHook\Phar\Symfony\Component\Console\Application->CaptainHook\Phar\Symfony\Component\Console\{closure}()
#5 phar:///home/omni/code/slack/captainhook.phar/bin/captainhook(63): CaptainHook\Phar\Symfony\Component\Console\Application->run()
#6 phar:///home/omni/code/slack/captainhook.phar/bin/captainhook(64): CaptainHook\Phar\{closure}()
#7 /home/omni/code/slack/captainhook.phar(17): require('...')
#8 {main}
  thrown in phar:///home/omni/code/slack/captainhook.phar/vendor/symfony/string/AbstractUnicodeString.php on line 29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants