consolidation / cgr

Safe replacement for `composer global require`
452 stars 24 forks source link

PHP Fatal error: Uncaught Error: Class 'Consolidation\Cgr\SystemInformation' not found in ~/.config/composer/vendor/consolidation/cgr/bin/cgr.php:17 #31

Open 86me opened 6 years ago

86me commented 6 years ago

Followed the installation instructions, added "~/.config/composer/vendor/bin" to my $PATH, then tried running cgr and get this error

PHP Fatal error:  Uncaught Error: Class 'Consolidation\Cgr\SystemInformation' not found in /home/86me/.config/composer/vendor/consolidation/cgr/bin/cgr.php:17
Stack trace:
#0 /home/86me/.config/composer/vendor/consolidation/cgr/bin/cgr(5): main(Array)
#1 {main}
  thrown in /home/86me/.config/composer/vendor/consolidation/cgr/bin/cgr.php on line 17

This is line 17 of cgr.php

$home = \Consolidation\Cgr\SystemInformation::getHomeDir();

What am I missing?

OS: Arch Composer version 1.7.2 2018-08-16 16:57:12

greg-1-anderson commented 6 years ago

Looks like your global autoloader does not include the cgr classes. You could try composer global dumpautoload, or maybe remove and re-add cgr.

Would it be preferable if cgr were provided as a phar? The installation instructions would then be:

  1. Download the phar from github
  2. chmod +x it
  3. Rename it to cgr and move it to your PATH (or symlink)

Updates would thereafter be done via cgr self:update (although cgr rarely needs updating).

The current installation method is just one line (if folks have already put the Composer global vendor bin in their path), but it seems that it has occasionally been unreliable for folks, and I'm not sure why. Maybe the phar would be more straightforward.