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

This skeleton is bust, causes Packager to Fail #13

Closed
XenitXTD opened this issue Sep 29, 2020 · 8 comments
Closed

This skeleton is bust, causes Packager to Fail #13

XenitXTD opened this issue Sep 29, 2020 · 8 comments

Comments

@XenitXTD
Copy link

Title Says it all and it effectively breaks the Packager

@Jeroen-G
Copy link
Owner

What's the error?

@XenitXTD
Copy link
Author

XenitXTD commented Oct 3, 2020

What's the error?

Hi,

So at time of writing

I perform a clean setup with "Laravel New Project" which sets up a new laravel 8.0.3 project

then I pull in your package with "composer require jeroen-g/laravel-packager"

once its installed I attempt to perform the "php artisan packager:new ACME ABC"

At the first step I see the following

0/6 [>---------------------------]   0% Creating package ACME\ABC...
Creating packages directory...
Creating vendor...
Downloading skeleton...

   ErrorException

  rename(/home/vagrant/Code/_packages/package_test/packages/ACME/ABC/src/MyPackage.php,/home/vagrant/Code/_packages/package_test/packages/ACME/ABC/src/ABC.php): No such file or directory

  at vendor/jeroen-g/laravel-packager/src/FileHandler.php:184
    180▕         ] : $manifest;
    181▕
    182▕         foreach ($rewrites as $file => $name) {
    183▕             $filename = str_replace($bindings[0], $bindings[1], $name);
  ➜ 184▕             rename($this->packagePath().'/'.$file, $this->packagePath().'/'.$filename);
    185▕         }
    186▕     }
    187▕
    188▕     /**

      +16 vendor frames
  17  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Looking in the packages directory I can see the ACME/ABC folder with what appears to be the skeleton source but it was never renamed etc.

This is a clean project, came here from reference on Laracasts and my experience has had no success with this package or skeleton

@Jeroen-G
Copy link
Owner

Jeroen-G commented Oct 4, 2020

Thank you, now I can look into it!

@Jeroen-G
Copy link
Owner

Jeroen-G commented Oct 9, 2020

On the latest release I was not able to reproduce it. Please try again!

@karmendra
Copy link

karmendra commented Dec 30, 2020

I am having laravel 8.20.1 installed with jeroen-g/laravel-packager v2.6 all this running on php 7.4.10 (on Homestead)

When I run php artisan packager:new foo/bar

I see it creates the boilerplate packages/foo/bar

but the files are not renamed as required.

Further investigation revealed that this code in public function renameFiles

    $files = new RecursiveDirectoryIterator($this->packagePath());
    foreach (new RecursiveIteratorIterator($files) as $file) {

Is causing the issue, the thing is RecursiveDirectoryIterator is not going inside the src and config folders thus is never picks the files inside those folder for renaming.

So I think problem is not this packager-skeleton but the laravel-packager

Can you please check?

Update:

Still further when I investigate, I figured there is no files in src folder when the RecursiveDirectoryIterator instance is created when it is running.

Instead of $this->packagePath() if I hardcode a directory path in new RecursiveDirectoryIterator($this->packagePath()); everything works fine.

@Jeroen-G
Copy link
Owner

That is very precise information and something I can work with, thank you. If you happen to find the solution, don't hesitate to open a PR!

@bilogic
Copy link

bilogic commented Apr 27, 2021

Jeroen-G/laravel-packager#101
Could this be due to the VirtualBox issue?

@Jeroen-G I'm facing it again, going to try and get to the root this time.

@XenitXTD
Copy link
Author

XenitXTD commented Oct 3, 2021

Hey there back again,

So I ran into this issue again and I was using a VM in this case homestead.

Looking at other user feedback and @bilogic link to a similar ticket this is actually a timing issue

so in my case I just went into the

Packager:New File

and just put a delay between the retrieval of the archive/extraction and the rename step

This could be a mix of several factors, system extract performance and file system speed on mount etc and the step may just be one step to fast and execute before the files are there to be renamed.

so I just added a sleep(2); to just give a bit of a delay

I will add that I tried this on the system directly and it worked no issue but the virtual environment was a permanent issue.

below is the adjustment I made just to get this working for me.

$manifest = (file_exists($this->conveyor->packagePath().'/rewriteRules.php')) ? $this->conveyor->packagePath().'/rewriteRules.php' : null;
        
sleep(2);
        
$this->conveyor->renameFiles($manifest);

@XenitXTD XenitXTD closed this as completed Oct 3, 2021
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

4 participants