From 6420e6d948f844c66935a3c0da2c7e187b43de7f Mon Sep 17 00:00:00 2001 From: Mohamad Eldhemy Date: Sat, 28 Jan 2023 11:39:11 +0200 Subject: [PATCH] fix(google): stop setting cred path twice - Fix #269 --- src/ServiceProviders/LiapServiceProvider.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ServiceProviders/LiapServiceProvider.php b/src/ServiceProviders/LiapServiceProvider.php index d9ff651..695ae96 100644 --- a/src/ServiceProviders/LiapServiceProvider.php +++ b/src/ServiceProviders/LiapServiceProvider.php @@ -112,8 +112,13 @@ private function registerConfig(): void { $this->mergeConfigFrom(self::CONFIG_PATH, self::CONFIG_KEY); - $googleCredentials = (string)config(self::CONFIG_KEY.'.google_application_credentials'); + // Check if it should set GOOGLE_APPLICATION_CREDENTIALS to the configured path + $currentGoogleCredPath = getenv('GOOGLE_APPLICATION_CREDENTIALS'); + if ($currentGoogleCredPath && file_exists($currentGoogleCredPath)) { + return; + } + $googleCredentials = (string)config(self::CONFIG_KEY.'.google_application_credentials'); if (! empty($googleCredentials) && ! is_dir($googleCredentials)) { if (! file_exists($googleCredentials)) { throw new RuntimeException("Google Application Credentials file not found at $googleCredentials");