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

failed to open stream: phar error: internal corruption of phar #193

Open
rainyroads opened this issue Mar 11, 2019 · 10 comments
Open

failed to open stream: phar error: internal corruption of phar #193

rainyroads opened this issue Mar 11, 2019 · 10 comments
Labels

Comments

@rainyroads
Copy link

After building, I am able to run my commandline application oncer, then on all subsequent commands I get an error about a filesize mismatch indicating that the PHAR is corrupted.



                Building process


   1. Moving application to production mode: ✔
   2. Compile into a single file: ✔

    Compiled successfully: /mnt/c/Users/makoto/Code/invision-dev-helper/builds/invision dev helper
makoto@DESKTOP-makotoH:/mnt/c/Users/makoto/Code/invision-dev-helper$
makoto@DESKTOP-makotoH:/mnt/c/Users/makoto/Code/invision-dev-helper$
makoto@DESKTOP-makotoH:/mnt/c/Users/makoto/Code/invision-dev-helper$ cp builds/invision\ dev\ helper builds/invision\ dev\ helper\ bkp
makoto@DESKTOP-makotoH:/mnt/c/Users/makoto/Code/invision-dev-helper$ ./builds/invision\ dev\ helper

  Invision dev helper  unreleased

  USAGE: invision dev helper <command> [options] [arguments]

  apps  View and manage installed IPS applications
  proxy (Re)generates all proxy classes for the application
makoto@DESKTOP-makotoH:/mnt/c/Users/makoto/Code/invision-dev-helper$ ./builds/invision\ dev\ helper
PHP Warning:  require(phar://box-auto-generated-alias-fedd654f3136.phar/.box/bin/check-requirements.php): failed to open stream: phar error: internal corruption of phar "/mnt/c/Users/makoto/Code/invision-dev-helper/builds/invision dev helper" (actual filesize mismatch on file ".box/bin/check-requirements.php") in /mnt/c/Users/makoto/Code/invision-dev-helper/builds/invision dev helper on line 12
PHP Fatal error:  require(): Failed opening required 'phar://box-auto-generated-alias-fedd654f3136.phar/.box/bin/check-requirements.php' (include_path='.:/usr/share/php') in /mnt/c/Users/makoto/Code/invision-dev-helper/builds/invision dev helper on line 12
makoto@DESKTOP-makotoH:/mnt/c/Users/makoto/Code/invision-dev-helper$

Public repository:
https://dev.taiga.sh/ips/invision-dev-helper

Builds before and after first run:
https://www.dropbox.com/s/aplqzqf88mhwaor/builds.zip?dl=0

(idh is after a fresh build, idh-bkp is after the first execution, where it therein fails further calls)

@rainyroads
Copy link
Author

A quick look at the PHAR's shows one has a storage directory and one doesn't.

11kwpEU

Seems like maybe laravel-dusk is causing issues here?

@rainyroads
Copy link
Author

Yep. That was the issue.

After removing laravel-dusk the applications working fine again,
composer remove nunomaduro/laravel-console-dusk

@nunomaduro
Copy link
Member

nunomaduro commented Mar 11, 2019 via email

@rainyroads
Copy link
Author

5.7.*, should be the latest build. I just started this project a week ago.

@nunomaduro
Copy link
Member

5.8 it's the latest version. I don't think it's the solution anyway.

You must declare a dynamic storage path on the console-dusk settings. Maybe @ijpatricio can give you a hand on this.

@ijpatricio
Copy link
Contributor

Hello @FujiMakoto,

Did you already try now with 5.8?

Are you still with this problem?

@nunomaduro nunomaduro reopened this Mar 13, 2019
@nunomaduro nunomaduro added the bug label Mar 13, 2019
@ijpatricio
Copy link
Contributor

@nunomaduro , while trying to find a temporary quick fix for this issue, I guess I solved the storage problem.

  • Installed Laravel-Zero
  • Installed component console-dusk
  • Published console-dusk configuration
 php myapplication vendor:publish --provider="NunoMaduro\LaravelConsoleDusk\LaravelConsoleDuskServiceProvider" --tag="config"
  • Made a class App\Build with contents:
<?php

namespace App;

class Build
{
    public static function buildStoragePath()
    {
        if (\Phar::running() !== ''){
            return \Phar::running($pharUrl = false);
        }

        return storage_path('laravel-console-dusk/screenshots');
    }
}

  • Put config/laravel-console-dusk.php like so:
<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Laravel Console Dusk Paths
    |--------------------------------------------------------------------------
    |
    | Here you may configure the name of screenshots and logs directory as you wish.
    */
    'paths' => [
        'screenshots' => \App\Build::buildStoragePath(),
        'log'         => \App\Build::buildStoragePath(),
    ],
];

So that when Phar is built, would use its location as the storage...

But now the issue is like below, and right now I have no idea what to do.

In HttpCommandExecutor.php line 292:

  Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chro
  me","platform":"ANY","chromeOptions":{"binary":"","args":["--disable-gpu","--headless"]}}}

  Failed to connect to localhost port 9515: Connection refused

image

@spmsupun
Copy link

spmsupun commented May 6, 2020

For me it was the storage folder, it was missing

@underdpt
Copy link

I'm being bitten by this.

I've tracked down the issue to the chromedriver being installed on vendor/laravel/dusk/bin/, and while this is being included on the phar file, it cannot be launched.

I've been looking a way to make this work, and I think there are two possible ways:

  1. Being able to modify the installation path for the chromedriver. This would involve patching upstream laravel/dusk to allow setting a custom location for the chromedriver path.
  2. Moving the chromedriver folder outside of the phar at build time, and then overloading Laravel\Dusk\Chrome\SupportsChrome::startChromeDriver() on src/Drivers/Chrome.php to detect at runtime if we're running inside a phar file and then using the alternative path for launching the chromedriver process. This would need patching upstream nunomaduro/laravel-console-dusk

I'll try the first approach as it seems more straightforward and could cover other use cases, but if anyone has other simpler solutions let me hear and I can try a PR.

@caendesilva
Copy link

Not sure if it's related, but I'm getting this after using the self-update command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

6 participants