Scribe documentation generation fails under Laravel-Vapor

206 Views Asked by At

I am runnig "php artisan scribe:generate" using vapor laravel commands, and get the job ends with errors, despite the fact that on my developement system (Laravel 10 on Windows 11) the same command runs without errors.

This is the output for php artisan scribe:generate in vapor command window:

Processing route: [GET] api/info Processed route: [GET] api/info Processing route: [POST] api/auth/login Processed route: [POST] api/auth/login Processing route: [POST] api/auth/hash Processed route: [POST] api/auth/hash Processing route: [POST] api/auth/logout Processed route: [POST] api/auth/logout Processing route: [GET] api/auth/role Processed route: [GET] api/auth/role Processing route: [GET] api/auth/permission Processed route: [GET] api/auth/permission Processing route: [GET] api/project Processed route: [GET] api/project Processing route: [GET] api/esolver/project/{project} Processed route: [GET] api/esolver/project/{project} Processing route: [GET] api/esolver/update/{project} Processed route: [GET] api/esolver/update/{project} Processing route: [GET] api/esolver/sync/{project} Processed route: [GET] api/esolver/sync/{project} Processing route: [POST] api/in_hook/new Processed route: [POST] api/in_hook/new Processing route: [POST] api/in_hook/start Processed route: [POST] api/in_hook/start Processing route: [POST] api/in_hook/stop Processed route: [POST] api/in_hook/stop Processing route: [POST] api/in_hook/delete Processed route: [POST] api/in_hook/delete Processing route: [POST] api/recipients/upload Processed route: [POST] api/recipients/upload Processing route: [POST] api/recipients/normalize Processed route: [POST] api/recipients/normalize Processing route: [POST] api/recipients/deduplicate Processed route: [POST] api/recipients/deduplicate Processing route: [GET] api/maps/show/{mapid?} Processed route: [GET] api/maps/show/{mapid?} Processing route: [POST] api/maps/set Processed route: [POST] api/maps/set Processing route: [PUT] api/maps/update Processed route: [PUT] api/maps/update Processing route: [DELETE] api/maps/remove/{mapid} Processed route: [DELETE] api/maps/remove/{mapid} Processing route: [POST] api/external/address Processed route: [POST] api/external/address

League\Flysystem\UnableToDeleteFile

Unable to delete file located at: /var/task/.scribe/endpoints/00.yaml.

at vendor/league/flysystem/src/UnableToDeleteFile.php:24 20▕ private $reason; 21▕ 22▕ public static function atLocation(string $location, string $reason = '', Throwable $previous = null): UnableToDeleteFile 23▕ { 24▕ $e = new static(rtrim("Unable to delete file located at: {$location}. {$reason}"), 0, $previous); 25▕ $e->location = $location; 26▕ $e->reason = $reason; 27▕ 28▕ return $e;

1 vendor/league/flysystem-local/LocalFilesystemAdapter.php:143 League\Flysystem\UnableToDeleteFile::atLocation("/var/task/.scribe/endpoints/00.yaml", "")

2 vendor/league/flysystem/src/Filesystem.php:85 League\Flysystem\Local\LocalFilesystemAdapter::delete(".scribe/endpoints/00.yaml")

3 vendor/knuckleswtf/scribe/src/Tools/Utils.php:212 League\Flysystem\Filesystem::delete(".scribe/endpoints/00.yaml")

4 vendor/knuckleswtf/scribe/src/GroupedEndpoints/GroupedEndpointsFromApp.php:191 Knuckles\Scribe\Tools\Utils::deleteFilesMatching(".scribe/endpoints", Object(Closure))

5 vendor/knuckleswtf/scribe/src/GroupedEndpoints/GroupedEndpointsFromApp.php:84 Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFromApp::writeEndpointsToDisk([])

6 vendor/knuckleswtf/scribe/src/GroupedEndpoints/GroupedEndpointsFromApp.php:49 Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFromApp::extractEndpointsInfoAndWriteToDisk(Object(Knuckles\Scribe\Matching\RouteMatcher))

7 vendor/knuckleswtf/scribe/src/Commands/GenerateDocumentation.php:51 Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFromApp::get()

8 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 Knuckles\Scribe\Commands\GenerateDocumentation::handle(Object(Knuckles\Scribe\Matching\RouteMatcher), Object(Knuckles\Scribe\GroupedEndpoints\GroupedEndpointsFactory))

9 vendor/laravel/framework/src/Illuminate/Container/Util.php:41 Illuminate\Container\BoundMethod::Illuminate\Container{closure}()

10 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 Illuminate\Container\Util::unwrapIfClosure(Object(Closure))

11 vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:35 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))

12 vendor/laravel/framework/src/Illuminate/Container/Container.php:662 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])

13 vendor/laravel/framework/src/Illuminate/Console/Command.php:208 Illuminate\Container\Container::call()

14 vendor/symfony/console/Command/Command.php:326 Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

15 vendor/laravel/framework/src/Illuminate/Console/Command.php:177 Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

16 vendor/symfony/console/Application.php:1081 Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

17 vendor/symfony/console/Application.php:320 Symfony\Component\Console\Application::doRunCommand(Object(Knuckles\Scribe\Commands\GenerateDocumentation), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

18 vendor/symfony/console/Application.php:174 Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

19 vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:201 Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

20 artisan:41 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Is there any one that experienced the same ?

1

There are 1 best solutions below

0
MartijnDB On

I've had this same problem. Unfortunately Scribe works with the local file system and this does not work in the Lambda instance. I've created an issue for this: https://github.com/knuckleswtf/scribe/issues/768

For now we are generating the docs locally and not in the CICD....


When deploying to vapor the error below occurs. I've tried Attaching Storage https://docs.vapor.build/resources/storage.html#attaching-storage And temporary storage https://docs.vapor.build/resources/storage.html#temporary-storage

This is the code where it is failing. Because (as I see it) it will always select a local filesystem, where vapor does not have/support one: https://github.com/knuckleswtf/scribe/blob/a720537cb6c03e8900d3ef800bdf3f27599e856e/src/Tools/Utils.php#L194

Exception:

Unable to delete file located at: /var/task/.scribe/endpoints/00.yaml.

  at vendor/league/flysystem/src/UnableToDeleteFile.php:24
     20▕     private $reason;
     21▕ 
     22▕     public static function atLocation(string $location, string $reason = '', Throwable $previous = null): UnableToDeleteFile
     23▕     {
  ➜  24▕         $e = new static(rtrim("Unable to delete file located at: {$location}. {$reason}"), 0, $previous);
     25▕         $e->location = $location;
     26▕         $e->reason = $reason;
     27▕ 
     28▕         return $e;

      +19 vendor frames 

  20  artisan:41
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))