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

Pusher being run at Laravel package:discover resulting in Argument Error #373

Open
williwlwilliwll opened this issue Jun 14, 2023 · 7 comments

Comments

@williwlwilliwll
Copy link

williwlwilliwll commented Jun 14, 2023

In my Dockerfile I have a step that installs Composer packages. After the installs are complete an artisan package:discover automatically executes and this errors out because Pusher can't find environment variables that it needs.

Why does Pusher actually get run by the package:discover command? Could I prefix the step in my Dockerfile with some 'temporary' env variables to get the build to succeed e.g. PUSHER_APP_KEY=foo PUSHER_APP_SECRET=bar composer install? Would this present any problems when I later to come set the actual values that I want when running the image as a container?

Cheers!

composer.json

 "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],

Terminal Output

#21 28.30 
#21 28.30    TypeError 
#21 28.30 
#21 28.30   Pusher\Pusher::__construct(): Argument #1 ($auth_key) must be of type string, null given, called in /var/www/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php on line 295
#21 28.30 
#21 28.30   at vendor/pusher/pusher-php-server/src/Pusher.php:63
#21 28.31      59▕      * @param ClientInterface|null $client [optional] - a Guzzle client to use for all HTTP requests
#21 28.31      60▕      *
#21 28.31      61▕      * @throws PusherException Throws exception if any required dependencies are missing
#21 28.31      62▕      */
#21 28.31   ➜  63▕     public function __construct(string $auth_key, string $secret, string $app_id, array $options = [], ClientInterface $client = null)
#21 28.31      64▕     {
#21 28.31      65▕         $this->check_compatibility();
#21 28.31      66▕ 
#21 28.31      67▕         if (!is_null($client)) {
@williwlwilliwll williwlwilliwll changed the title Why is Pusher being run at Laravel package:discover - Argument Error Pusher being run at Laravel package:discover resulting in Argument Error Jun 14, 2023
@stale
Copy link

stale bot commented Sep 16, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you'd like this issue to stay open please leave a comment indicating how this issue is affecting you. Thank you.

@stale stale bot added the wontfix label Sep 16, 2023
@williwlwilliwll
Copy link
Author

Please keep this issue open, I think it is a valid question

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you'd like this issue to stay open please leave a comment indicating how this issue is affecting you. Thank you.

@stale stale bot removed the wontfix label Sep 18, 2023
@watkit
Copy link

watkit commented Nov 19, 2023

I've just encountered the same problem. Seems a straightforward question, strange not to get an answer.

@williwlwilliwll
Copy link
Author

williwlwilliwll commented Nov 20, 2023

@watkit

I have added the following code to my Dockerfile:

RUN export PUSHER_APP_ID="123abc" \
    && export PUSHER_APP_KEY="abc123" \
    && export PUSHER_APP_SECRET="1a2b3c" \
    && curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
    && composer install \
    && composer clear-cache

This circumvents the problem but it would still be nice to have a response from the project owners about why this is necessary at all.

@watkit
Copy link

watkit commented Nov 26, 2023

Ah, good workaround, thanks for sharing!
I ended up figuring out a way to maintain a .env file in prod and setting environment variables from there, in a similar vein to your Dockerfile idea, but would be handy for pusher (or laravel for my case) to have a supported way to manage this.

@Fuel0
Copy link

Fuel0 commented Dec 3, 2023

I got same problem here, can't install project because of it

@benw-pusher
Copy link

I believe this is a result of the integration of Pusher (specifically this library) into the Laravel framework. package:discover registers service providers, and this process may be looking for the values identified in #373 (comment).

You can prevent a library from being discovered with the below:

"extra": {
    "laravel": {
        "dont-discover": [
            "pusher/pusher-php-server"
        ]
    }
}

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