HELP: Uncaught Error: Class 'Crawler' not found

Hi! I downloaded the latest 4.0.1 self-hosted zip to evaluate I.N. for a client, and am getting this error:

PHP Fatal error:  Uncaught Error: Class 'Crawler' not found in /opt/ninja/app/Exceptions/Handler.php:53
Stack trace:
#0 /opt/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(320): App\Exceptions\Handler->report(Object(Dotenv\Exception\InvalidFileException))
#1 /opt/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(123): Illuminate\Foundation\Console\Kernel->reportException(Object(Dotenv\Exception\InvalidFileException))
#2 /opt/ninja/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 {main}
  thrown in /opt/ninja/app/Exceptions/Handler.php on line 53

This happens both via web and using any artisan command. I tried commenting out the Crawler references, but then get a similar message regarding class Utils. I’ve tried the various suggestions via the Troubleshooting section and others from the forums and github issues, but no luck. I tried using a zip from github as well, but same thing.

This is a brand new install on a Ubuntu 16.04 system, using php 7.0.26.

Any other suggestions on what I might be missing?

Thanks!

Did you try running composer install after downloading the code from GitHub?

I didn’t think that was necessary with the self-hosted ZIP, but I just tried it and get the same error:


$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 29 installs, 0 updates, 0 removals
  - Installing codeception/c3 (2.0.14): Loading from cache
[codeception/c3] c3.php is already up-to-date
  - Installing symfony/dom-crawler (v3.4.0): Downloading (100%)
  - Installing symfony/browser-kit (v3.4.0): Downloading (100%)
  - Installing stecman/symfony-console-completion (0.7.0): Downloading (100%)
  - Installing sebastian/diff (1.4.3): Downloading (100%)
  - Installing sebastian/recursion-context (1.0.5): Downloading (100%)
  - Installing sebastian/exporter (1.2.2): Downloading (100%)
  - Installing sebastian/comparator (1.2.4): Downloading (100%)
  - Installing phpunit/php-text-template (1.2.1): Downloading (100%)
  - Installing doctrine/instantiator (1.0.5): Downloading (100%)
  - Installing phpunit/phpunit-mock-objects (2.3.8): Downloading (100%)
  - Installing sebastian/version (1.0.6): Downloading (100%)
  - Installing sebastian/global-state (1.1.1): Downloading (100%)
  - Installing sebastian/environment (1.3.8): Downloading (100%)
  - Installing phpunit/php-timer (1.0.9): Downloading (100%)
  - Installing phpunit/php-file-iterator (1.4.5): Downloading (100%)
  - Installing phpunit/php-token-stream (1.4.11): Downloading (100%)
  - Installing phpunit/php-code-coverage (2.2.4): Downloading (100%)
  - Installing webmozart/assert (1.2.0): Downloading (100%)
  - Installing phpdocumentor/reflection-common (1.0.1): Downloading (100%)
  - Installing phpdocumentor/type-resolver (0.4.0): Downloading (100%)
  - Installing phpdocumentor/reflection-docblock (4.2.0): Downloading (100%)
  - Installing phpspec/prophecy (1.7.3): Downloading (100%)
  - Installing phpunit/phpunit (4.8.36): Downloading (100%)
    Skipped installation of bin phpunit for package phpunit/phpunit: name conflicts with an existing file
  - Installing facebook/webdriver (1.5.0): Downloading (100%)
  - Installing behat/gherkin (v4.4.5): Downloading (100%)
  - Installing codeception/codeception (2.3.3): Downloading (100%)
    Skipped installation of bin codecept for package codeception/codeception: name conflicts with an existing file
  - Installing phpspec/php-diff (v1.0.2): Downloading (100%)
  - Installing phpspec/phpspec (2.5.8): Downloading (100%)
    Skipped installation of bin bin/phpspec for package phpspec/phpspec: name conflicts with an existing file
phpunit/phpunit-mock-objects suggests installing ext-soap (*)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
codeception/codeception suggests installing codeception/specify (BDD-style code blocks)
codeception/codeception suggests installing codeception/verify (BDD-style assertions)
codeception/codeception suggests installing flow/jsonpath (For using JSONPath in REST module)
codeception/codeception suggests installing league/factory-muffin (For DataFactory module)
codeception/codeception suggests installing flow/jsonpath (For using JSONPath in REST module)
codeception/codeception suggests installing league/factory-muffin (For DataFactory module)
codeception/codeception suggests installing league/factory-muffin-faker (For Faker support in DataFactory module)
codeception/codeception suggests installing symfony/phpunit-bridge (For phpunit-bridge support)
phpspec/phpspec suggests installing phpspec/nyan-formatters (~1.0 – Adds Nyan formatters)
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
Package chumper/datatable is abandoned, you should avoid using it. Use OpenSkill/Datatable instead.
Package league/url is abandoned, you should avoid using it. Use league/uri instead.
Package illuminate/html is abandoned, you should avoid using it. Use laravelcollective/html instead.
Generating optimized autoload files
> php artisan clear-compiled
PHP Fatal error:  Uncaught Error: Class 'Crawler' not found in /opt/ninja/app/Exceptions/Handler.php:53
Stack trace:
#0 /opt/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(320): App\Exceptions\Handler->report(Object(Dotenv\Exception\InvalidFileException))
#1 /opt/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(123): Illuminate\Foundation\Console\Kernel->reportException(Object(Dotenv\Exception\InvalidFileException))
#2 /opt/ninja/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 {main}
  thrown in /opt/ninja/app/Exceptions/Handler.php on line 53
Script php artisan clear-compiled handling the post-install-cmd event returned with error code 255

It’s just needed with the code from GitHub.

Can you post the error you see when commenting out the crawler references.

Have you tried running chmod -R 777 storage then chmod -R 755 storage, it also may help to delete bootstrap/cache/services.php if it exists.

I commented out the Crawler refs, flipped the permissions and tried again:


gjh@restya:/opt/ninja$ php artisan optimize
PHP Fatal error:  Uncaught Error: Class 'Utils' not found in /opt/ninja/app/Exceptions/Handler.php:72
Stack trace:
#0 /opt/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(320): App\Exceptions\Handler->report(Object(Dotenv\Exception\InvalidFileException))
#1 /opt/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(123): Illuminate\Foundation\Console\Kernel->reportException(Object(Dotenv\Exception\InvalidFileException))
#2 /opt/ninja/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 {main}
  thrown in /opt/ninja/app/Exceptions/Handler.php on line 72

Then I deleted the bootstrap/cache files, but get the exact same error as above.

I’m not sure why you’re seeing the error, the Utils class should be included here:

https://github.com/invoiceninja/invoiceninja/blob/master/app/Exceptions/Handler.php#L18

You can try commenting out this section of code:

https://github.com/invoiceninja/invoiceninja/blob/master/app/Exceptions/Handler.php#L72

Ah, so clearing that out yielded a new error:


gjh@restya:/opt/ninja$ php artisan optimize
PHP Fatal error:  Uncaught Dotenv\Exception\InvalidFileException: Dotenv values containing spaces must be surrounded by quotes. in /opt/ninja/vendor/vlucas/phpdotenv/src/Loader.php:228
Stack trace:
#0 /opt/ninja/vendor/vlucas/phpdotenv/src/Loader.php(97): Dotenv\Loader->sanitiseVariableValue('MAIL_FROM_NAME', 'FCC Invoice Nin...')
#1 /opt/ninja/vendor/vlucas/phpdotenv/src/Loader.php(330): Dotenv\Loader->normaliseEnvironmentVariable('MAIL_FROM_NAME', 'FCC Invoice Nin...')
#2 /opt/ninja/vendor/vlucas/phpdotenv/src/Loader.php(58): Dotenv\Loader->setEnvironmentVariable('MAIL_FROM_NAME=...')
#3 /opt/ninja/vendor/vlucas/phpdotenv/src/Dotenv.php(91): Dotenv\Loader->load()
#4 /opt/ninja/vendor/vlucas/phpdotenv/src/Dotenv.php(48): Dotenv\Dotenv->loadData()
#5 /opt/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/DetectEnvironment.php(24): Dotenv\Dotenv->load()
#6 /opt/ninja/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\DetectEnvironment->bootstrap(Object(Illum in /opt/ninja/vendor/vlucas/phpdotenv/src/Loader.php on line 228

I indeed did have an unescaped value in my .env file, so that error must not be getting trapped and thus breaking the app. Once I quoted the value (MAIL_FROM_NAME), the app loads and I can proceed with my evaluation.

Would you like me to file a bug report? I haven’t done anything in Laravel so not sure (how quickly) I could help with a PR.

Thanks for helping me through this!

This isn’t a bug, the .env file doesn’t support having spaces.

Hmm… maybe it is a bug, you should see the .env error not the ‘Crawler not found’ error.

We’ll look into it.

Yeah, I only meant the bug was that the true error is getting swallowed. It took me many hours to eventually figure out my simple problem. :slight_smile:

Thanks again!

Sorry for the wasted time! Hopefully the awesomeness of the app makes up for it :slight_smile:

We’ve checked in a fix which will be included with our next release, at least your efforts will help others.

Excellent, glad I could help!