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

"LogManager not found in ..." when Sail uses PHP8.1 build. #286

Closed
dima2306 opened this issue Nov 20, 2021 · 13 comments
Closed

"LogManager not found in ..." when Sail uses PHP8.1 build. #286

dima2306 opened this issue Nov 20, 2021 · 13 comments
Assignees

Comments

@dima2306
Copy link

  • Sail Version: 1.12.3
  • Docker compose version: 1.29.2
  • Laravel Version: 8.69.0
  • PHP Version: 8.1.0RC6 (cli) (built: Nov 19 2021 06:50:24) (NTS)
  • OS: Linux / Fedora 34
  • docker-compose.yml:
version: '3'
services:
  sail.test:
    build:
      context: ./vendor/laravel/sail/runtimes/8.1
      dockerfile: Dockerfile
      args:
        WWWGROUP: '${WWWGROUP}'
    image: sail-8.1/app
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    ports:
      - '${APP_PORT:-8082}:80'
    environment:
      WWWUSER: '${WWWUSER}'
      LARAVEL_SAIL: 1
      XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
      XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
    volumes:
      - '.:/var/www/html'
    networks:
      - sail
    depends_on:
      - mysql
  mysql:
    image: 'mysql:8.0'
    ports:
      - '${FORWARD_DB_PORT:-3306}:3306'
    environment:
      MYSQL_ROOT_PASSWORD: '${DB_ROOT_PASSWORD}'
      MYSQL_DATABASE: '${DB_DATABASE}'
      MYSQL_USER: '${DB_USERNAME}'
      MYSQL_PASSWORD: '${DB_PASSWORD}'
    volumes:
      - 'sailmysql:/var/lib/mysql'
    networks:
      - sail
    healthcheck:
      test: [ "CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}" ]
      retries: 3
      timeout: 5s
networks:
  sail:
    driver: bridge
volumes:
  sailmysql:
    driver: local

Description:

So I chose PHP 8.1 version and ran the command sail build --no-cache then sail up. The first request is fine but after reloading the page I'm getting the error:

[Sat Nov 20 10:56:38 2021] PHP Fatal error:  Uncaught Error: Class "Illuminate\Log\LogManager" not found in /var/www/html/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php:17
2021-11-20T10:56:38.632398553Z Stack trace:
2021-11-20T10:56:38.632401032Z #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(873): Illuminate\Log\LogServiceProvider->Illuminate\Log\{closure}()
2021-11-20T10:56:38.632403721Z #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container->build()
2021-11-20T10:56:38.632406279Z #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->resolve()
2021-11-20T10:56:38.632409307Z #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve()
2021-11-20T10:56:38.632413199Z #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\Container\Container->make()
2021-11-20T10:56:38.632417792Z #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(89): Illuminate\Foundation\Application->make()
2021-11-20T10:56:38.632422247Z #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions->handleDeprecation()
2021-11-20T10:56:38.632427491Z #7 /var/www/html/vendor/composer/ClassLoader.php(571): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
2021-11-20T10:56:38.632431532Z #8 /var/www/html/vendor/composer/ClassLoader.php(571): include('...')
2021-11-20T10:56:38.632434073Z #9 /var/www/html/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
2021-11-20T10:56:38.632436722Z #10 /var/www/html/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php(17): Composer\Autoload\ClassLoader->loadClass()
2021-11-20T10:56:38.632439362Z #11 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(873): Illuminate\Log\LogServiceProvider->Illuminate\Log\{closure}()
2021-11-20T10:56:38.632441981Z #12 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container->build()
2021-11-20T10:56:38.632444705Z #13 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->resolve()
2021-11-20T10:56:38.632447386Z #14 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve()
2021-11-20T10:56:38.632450034Z #15 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\Container\Container->make()
2021-11-20T10:56:38.632452730Z #16 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(242): Illuminate\Foundation\Application->make()
2021-11-20T10:56:38.632455369Z #17 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(136): Illuminate\Foundation\Exceptions\Handler->report()
2021-11-20T10:56:38.632462740Z #18 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(178): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException()
2021-11-20T10:56:38.632465931Z #19 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
2021-11-20T10:56:38.632468527Z #20 {main}
2021-11-20T10:56:38.632470936Z   thrown in /var/www/html/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php on line 17

Changing the LOG_CHANNEL env variable to file, stdout, etc. helps for the first request again and then the same issue arises.

Downgrading the PHP version to 8 fixes the problem.

Steps To Reproduce:

In docker-compose.yml replace the PHP version with 8.1. Run the command sail build --no-cache, then sail up and see the result after reloading a page several times.

@driesvints
Copy link
Member

I can't reproduce this issue. Everything works as expected with 8.1

@jcs224
Copy link

jcs224 commented Dec 1, 2021

I can confirm this issue. First request works, then each subsequent request fails with this output.

Also on Linux, Pop!_OS 21.04

@kyryl-bogach
Copy link

kyryl-bogach commented Dec 2, 2021

I am having this issue with 8.1 too.

Ubuntu 21.04

@jcs224
Copy link

jcs224 commented Dec 2, 2021

In the meantime I literally just copied the config from the 8.1 docker folder to 8.0, did a find-replace changing all occurrences of 8.1 to 8.0, and ran 8.0 instead of 8.1 from docker-compose.yml. Now it works!.

It seems to be something to do with the combination of Docker/Sail, Linux, and PHP 8.1 🤔 My Windows colleague doesn't seem to have this issue. @driesvints to reproduce it, it might require running Sail with 8.1 in a Linux VM or something.

@driesvints
Copy link
Member

In the meantime I literally just copied the config from the 8.1 docker folder to 8.0, did a find-replace changing all occurrences of 8.1 to 8.0, and ran 8.0 instead of 8.1 from docker-compose.yml. Now it works!.

What were the changes?

@jcs224
Copy link

jcs224 commented Dec 2, 2021

I just took my custom Dockerfile for 8.1 and converted it to 8.0 by doing a find and replace. Vast majority of changes were just which php extensions to download, like php8.1-sqlite to php8.0-sqlite. This fixes my issue, so now I have an environment seemingly identical as before, except the PHP version. I can't really logically explain it, because the only thing I changed was the PHP version. Same Ubuntu version in docker, all other packages the same.

Here are some other environment specs:

  • Docker version: 20.10.7
  • OS: Pop!_OS 21.04 (based on Ubuntu)

@jcs224
Copy link

jcs224 commented Dec 3, 2021

Oddly, it's working for me now... but it doesn't work immediately after running sail build --no-cache. It's only after shutting down 8.1, switching to 8.0, then switching back to 8.1. I would almost guess it's something to do with something not getting cleaned up correctly switching from 8.0 to 8.1 🤔

@SteveEdson
Copy link

SteveEdson commented Dec 5, 2021

Also having the exact same issue.

php -v
PHP 8.1.0 (cli) (built: Nov 28 2021 01:31:19) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies

Running through php artisan serve, on a M1 Pro Mac

@driesvints
Copy link
Member

@SteveEdson this is the issue tracker for Sail so if you say this is happening through artisan serve then that seems to be a general framework issue? I haven't been able to reproduce this at all. If anyone can give me a clear way to reproduce this on a vanilla Laravel install without Sail then I can have a look.

@gofish543
Copy link

@driesvints I've been hounding this issue now for about 8 hours and I've traced through hundreds of errors, but was finally able to get it to a repdocueable state.

PHP 8.1
Laravel 8.75.0
Both MacOS and Ubuntu 21.04

The issue revolves around the Illuminate\Foundation\Kernel@handle function.
Throw a throw new \Exception within the handle function like below...
This forces an exception through the exception handler.
The behavior is then extremely inconsistent. Sometimes there is a config not defined. Other times it is a LogManager not found.

  /**
     * Handle an incoming HTTP request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function handle($request)
    {
        try {
            $request->enableHttpMethodParameterOverride();

            throw new \Exception();

            $response = $this->sendRequestThroughRouter($request);
        } catch (Throwable $e) {
            $this->reportException($e);

            dd("I should make it here safely... correct?");
            $response = $this->renderException($request, $e);
        }

        $this->app['events']->dispatch(
            new RequestHandled($request, $response)
        );

        return $response;
    }

This is the end of my debugging, but there is a problem here and it is directly related to php 8.1.

@gofish543
Copy link

@driesvints
Continuing... I can force a class not found Illuminate\Log\LogManager error to occur by running php artisan serve and loading the page exactly 2 times. This is also sparely repeatable when using Laravel Valet on Mac OS

image

If I do not have the dump statement within the code the error is a silent failure and leaves the user with a WSOD (White Screen of Death) exception.

@nunomaduro
Copy link
Member

This issue should be fixed in the next Laravel Framework version. So, next week.

@Levivb
Copy link

Levivb commented Apr 20, 2022

It seems to be related to a bug in php's opcache: php/php-src#8164

Will leave a comment there tomorrow

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

8 participants