laravel / jetstream

Tailwind scaffolding for the Laravel framework.
https://jetstream.laravel.com
MIT License
3.98k stars 822 forks source link

Laravel 11 compatibility? "Target [Laravel\Fortify\Contracts\CreatesNewUsers] is not instantiable." #1451

Closed maxleistner closed 8 months ago

maxleistner commented 8 months ago

Jetstream Version

5

Jetstream Stack

Livewire

Laravel Version

11.0.5

PHP Version

8.3

Database Driver & Version

mysql sail

Description

After going through all installation steps i get. the following error trying to register:

Target [Laravel\Fortify\Contracts\CreatesNewUsers] is not instantiable.

Steps To Reproduce

Install laravel 11 with sail Install JetStream Livewire + Tams

https://flareapp.io/share/NPGZ9nNm#stack

maxleistner commented 8 months ago

I found the error:

App\Providers\FortifyServiceProvider::class, was missing from bootstrap/providers.php. After the following code changes it works:

<?php

return [
    App\Providers\AppServiceProvider::class,
    App\Providers\JetstreamServiceProvider::class,
    App\Providers\FortifyServiceProvider::class,
];
driesvints commented 8 months ago

@maxleistner I tried this and it just adds the service provider for me. If you have this issue still please provide a very detailed list of steps to reproduce.

sotten commented 8 months ago

@driesvints

I can also confirm this. Commands to reproduce this under Ubuntu 22.04 LTS:

curl -s https://laravel.build/testapp2 | bash
cd testapp2 && ./vendor/bin/sail up -d && ./vendor/bin/sail composer require laravel/jetstream && ./vendor/bin/sail artisan jetstream:install livewire && ./vendor/bin/sail artisan test

should produce this output:

   PASS  Tests\Unit\ExampleTest
  ✓ that true is true

   WARN  Tests\Feature\ApiTokenPermissionsTest
  - api token permissions can be updated → API support is not enabled.                                                                                                                                      1.95s  

   PASS  Tests\Feature\AuthenticationTest
  ✓ login screen can be rendered                                                                                                                                                                            0.08s  
  ✓ users can authenticate using the login screen                                                                                                                                                           0.07s  
  ✓ users can not authenticate with invalid password                                                                                                                                                        0.03s  

   PASS  Tests\Feature\BrowserSessionsTest
  ✓ other browser sessions can be logged out                                                                                                                                                                0.06s  

   WARN  Tests\Feature\CreateApiTokenTest
  - api tokens can be created → API support is not enabled.                                                                                                                                                 0.01s  

   PASS  Tests\Feature\DeleteAccountTest
  ✓ user accounts can be deleted                                                                                                                                                                            0.05s  
  ✓ correct password must be provided before account can be deleted                                                                                                                                         0.04s  

   WARN  Tests\Feature\DeleteApiTokenTest
  - api tokens can be deleted → API support is not enabled.                                                                                                                                                 0.01s  

   WARN  Tests\Feature\EmailVerificationTest
  - email verification screen can be rendered → Email verification not enabled.                                                                                                                             0.01s  
  - email can be verified → Email verification not enabled.                                                                                                                                                 0.01s  
  - email can not verified with invalid hash → Email verification not enabled.                                                                                                                              0.01s  

   PASS  Tests\Feature\ExampleTest
  ✓ the application returns a successful response                                                                                                                                                           0.02s  

   PASS  Tests\Feature\PasswordConfirmationTest
  ✓ confirm password screen can be rendered                                                                                                                                                                 0.04s  
  ✓ password can be confirmed                                                                                                                                                                               0.03s  
  ✓ password is not confirmed with invalid password                                                                                                                                                         0.23s  

   PASS  Tests\Feature\PasswordResetTest
  ✓ reset password link screen can be rendered                                                                                                                                                              0.06s  
  ✓ reset password link can be requested                                                                                                                                                                    0.05s  
  ✓ reset password screen can be rendered                                                                                                                                                                   0.04s  
  ✓ password can be reset with valid token                                                                                                                                                                  0.08s  

   FAIL  Tests\Feature\ProfileInformationTest
  ✓ current profile information is available                                                                                                                                                                0.05s  
  ⨯ profile information can be updated                                                                                                                                                                      0.03s  

   FAIL  Tests\Feature\RegistrationTest
  ✓ registration screen can be rendered                                                                                                                                                                     0.03s  
  - registration screen cannot be rendered if support is disabled → Registration support is enabled.                                                                                                        0.01s  
  ⨯ new users can register                                                                                                                                                                                  0.04s  

   PASS  Tests\Feature\TwoFactorAuthenticationSettingsTest
  ✓ two factor authentication can be enabled                                                                                                                                                                0.13s  
  ✓ recovery codes can be regenerated                                                                                                                                                                       0.24s  
  ✓ two factor authentication can be disabled                                                                                                                                                               0.11s  

   FAIL  Tests\Feature\UpdatePasswordTest
  ⨯ password can be updated                                                                                                                                                                                 0.05s  
  ⨯ current password must be correct                                                                                                                                                                        0.04s  
  ⨯ new passwords must match                                                                                                                                                                                0.03s  
  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Feature\ProfileInformationTest > profile information can be updated                                                                                                  BindingResolutionException   
  Target [Laravel\Fortify\Contracts\UpdatesUserProfileInformation] is not instantiable.

  at vendor/laravel/framework/src/Illuminate/Container/Container.php:1118
    1114▕         } else {
    1115▕             $message = "Target [$concrete] is not instantiable.";
    1116▕         }
    1117▕ 
  ➜ 1118▕         throw new BindingResolutionException($message);
    1119▕     }
    1120▕ 
    1121▕     /**
    1122▕      * Throw an exception for an unresolvable primitive.

      +40 vendor frames 
  41  tests/Feature/ProfileInformationTest.php:31

  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Feature\RegistrationTest > new users can register                                                                                                                                                 
  The user is not authenticated
Failed asserting that false is true.

  at tests/Feature/RegistrationTest.php:50
     46▕             'password_confirmation' => 'password',
     47▕             'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature(),
     48▕         ]);
     49▕ 
  ➜  50▕         $this->assertAuthenticated();
     51▕         $response->assertRedirect(route('dashboard', absolute: false));
     52▕     }
     53▕ }
     54▕ 

  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Feature\UpdatePasswordTest > password can be updated                                                                                                                 BindingResolutionException   
  Target [Laravel\Fortify\Contracts\UpdatesUserPasswords] is not instantiable.

  at vendor/laravel/framework/src/Illuminate/Container/Container.php:1118
    1114▕         } else {
    1115▕             $message = "Target [$concrete] is not instantiable.";
    1116▕         }
    1117▕ 
  ➜ 1118▕         throw new BindingResolutionException($message);
    1119▕     }
    1120▕ 
    1121▕     /**
    1122▕      * Throw an exception for an unresolvable primitive.

      +40 vendor frames 
  41  tests/Feature/UpdatePasswordTest.php:26

  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Feature\UpdatePasswordTest > current password must be correct                                                                                                        BindingResolutionException   
  Target [Laravel\Fortify\Contracts\UpdatesUserPasswords] is not instantiable.

  at vendor/laravel/framework/src/Illuminate/Container/Container.php:1118
    1114▕         } else {
    1115▕             $message = "Target [$concrete] is not instantiable.";
    1116▕         }
    1117▕ 
  ➜ 1118▕         throw new BindingResolutionException($message);
    1119▕     }
    1120▕ 
    1121▕     /**
    1122▕      * Throw an exception for an unresolvable primitive.

      +40 vendor frames 
  41  tests/Feature/UpdatePasswordTest.php:41

  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Feature\UpdatePasswordTest > new passwords must match                                                                                                                BindingResolutionException   
  Target [Laravel\Fortify\Contracts\UpdatesUserPasswords] is not instantiable.

  at vendor/laravel/framework/src/Illuminate/Container/Container.php:1118
    1114▕         } else {
    1115▕             $message = "Target [$concrete] is not instantiable.";
    1116▕         }
    1117▕ 
  ➜ 1118▕         throw new BindingResolutionException($message);
    1119▕     }
    1120▕ 
    1121▕     /**
    1122▕      * Throw an exception for an unresolvable primitive.

      +40 vendor frames 
  41  tests/Feature/UpdatePasswordTest.php:57

  Tests:    5 failed, 7 skipped, 20 passed (33 assertions)
  Duration: 3.79s
ronald2wing commented 8 months ago

@maxleistner This should not be set to completed until merged into the main branch.

driesvints commented 8 months ago

@maxleistner @sotten do you both have opcache enabled by any chance?

maxleistner commented 8 months ago

@maxleistner @sotten do you both have opcache enabled by any chance?

I am "just" using the composer commands to install sail and did not change anything on the docker image or compose.

driesvints commented 8 months ago

@maxleistner can you check if opcache is enabled?

sail php -i | grep opcache.enable          
maxleistner commented 8 months ago

@maxleistner can you check if opcache is enabled?

sail php -i | grep opcache.enable          

https://app.warp.dev/block/kDq4xPfw8BCm5jPYrbl1vy

opcache.enable => On => On
opcache.enable_cli => On => On
opcache.enable_file_override => Off => Off
driesvints commented 8 months ago

Thanks @maxleistner. Gonna close this one in favour of https://github.com/laravel/jetstream/issues/1454 which is the same thing and Jess is already investigating there.