You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 6, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Jan 6, 2023. It is now read-only.
Fatal error: require_once() when activating GCS Media plugin #49
Hi got these two errors when activating the GCS Media plugin:
Warning: require_once(/Users/(...)/wordpress/wp-content/plugins/gcs-media/vendor/autoload.php): failed to open stream: No such file or directory in /Users/(...)/wordpress/wp-content/plugins/gcs-media/gcs.php on line 33
Fatal error: require_once(): Failed opening required '/Users/(...)/wordpress/wp-content/plugins/gcs-media/vendor/autoload.php' (include_path='.:/Users/(...):/Users/(...)/google-cloud-sdk/platform/google_appengine/php/sdk') in /Users/(...)/wordpress/wp-content/plugins/gcs-media/gcs.php on line 33
And just like @ccherchi I ran into this issue. Is there still no fix for this? Since I ran since in a clean GCP project, I am imagining that other users following the tutorial will experience exactly the same issue.
So it turns out that the vendor folder inside of the gcs plugin isn't even being uploaded when running the gcloud app deploy command, as the tutorial suggests. See the screenshot below.
Commenting out the following line from the .gcloudignore file in the root of my project directory and redeploying my site to App Engine resolved the issue, as the vendor folder was included this time. I don't know if this is best practice but it did work for me.
@sebastianbk Actually, @DeanMarkTaylor kinda has the answer for you. The vendor folder is missing because it's supposed to be built for you when you deploy when it runs Composer automatically for you. So I'd check your composer.json.
@ran-dall Well, I have no composer.json in my project structure. I'm certainly not a PHP guy so I just learned about Composer yesterday. My point is just that I followed the tutorial on GCP's website, step by step, and it didn't work, which puzzled me quite a bit.
The problem is exactly what @sebastianbk described above. The first time you run gcloud app deploy, it generates a .gcloudignore which adds /vendor/ but Google bundles vendor dependencies directly in the gcs plugin so it's preventing itself from working.
I ended up removing it from both .gcloudignore and .gitignore to make it easy to develop and deploy.
@FrankM1 and @Zertz When you upload an application, you should be specifying your dependencies in a composer.json file. When Composer runs, it will automatically create the vendor directories.
The ignored action is best practice, as you shouldn't be committing your vendor directories. It only ignores the instances of the dependencies you have locally installed in your system; only so that when you commit the codebase to AppEngine, it triggers to create its own set of dependencies. In that process, the vendor directories should be recreated from the source, and you'd end up with the same system.
By default, the vendor/ directory is ignored in the generated .gcloudignore file to reduce the number of files sent in deployment.
So for clarity, the local dependencies don't get transferred but essentially get recreated by AppEngine.
Ignoring vendor/ is a problem since there are plugins that use composer to bundle libraries.
You can install plugins through Composer package; although not every plugin is available. You can check on Packagist, if the plugin is available as a Composer package. You also need to make sure that the plugin is listed properly in the composer.json. Unfortunately, though there isn't a ready-made package for this plugin yet, but there are packages for other GCS plugins that accomplish the same thing. If you're set on using this particular plugin though, there are a few workarounds for installing plugins that aren't packaged yet, such as https://stackoverflow.com/questions/16847994/how-do-you-get-composer-to-install-a-non-composer-package.
Thank you @ran-dall This indeed does clarify a few points for me. 90% of plugins I deploy to app engine are in private repos. I'll need to figure out how to add those using composer. What you describe does make sense.
Activity
sebastianbk commentedon Apr 9, 2019
I followed the steps of GCP's tutorial here: https://cloud.google.com/community/tutorials/run-wordpress-on-appengine-standard
And just like @ccherchi I ran into this issue. Is there still no fix for this? Since I ran since in a clean GCP project, I am imagining that other users following the tutorial will experience exactly the same issue.
sebastianbk commentedon Apr 9, 2019
So it turns out that the
vendorfolder inside of thegcsplugin isn't even being uploaded when running thegcloud app deploycommand, as the tutorial suggests. See the screenshot below.Commenting out the following line from the
.gcloudignorefile in the root of my project directory and redeploying my site to App Engine resolved the issue, as thevendorfolder was included this time. I don't know if this is best practice but it did work for me.DeanMarkTaylor commentedon Apr 10, 2019
I've not dug into this myself - you might find this useful though...
You can find details relating to this here:
https://cloud.google.com/appengine/docs/standard/php7/specifying-dependencies
Note the following:
vendor/directory is ignored in the generated .gcloudignore file to reduce the number of files sent in deployment.No real answers from me here, just an observation.
ran-dall commentedon Apr 10, 2019
@sebastianbk Actually, @DeanMarkTaylor kinda has the answer for you. The
vendorfolder is missing because it's supposed to be built for you when you deploy when it runsComposerautomatically for you. So I'd check yourcomposer.json.sebastianbk commentedon Apr 10, 2019
@ran-dall Well, I have no
composer.jsonin my project structure. I'm certainly not a PHP guy so I just learned about Composer yesterday. My point is just that I followed the tutorial on GCP's website, step by step, and it didn't work, which puzzled me quite a bit.Zertz commentedon May 9, 2019
The problem is exactly what @sebastianbk described above. The first time you run
gcloud app deploy, it generates a.gcloudignorewhich adds/vendor/but Google bundles vendor dependencies directly in thegcsplugin so it's preventing itself from working.I ended up removing it from both
.gcloudignoreand.gitignoreto make it easy to develop and deploy.FrankM1 commentedon May 20, 2019
Ignoring
vendor/is a problem since there are plugins that use composer to bundle libraries. This means those too will malfunction.ran-dall commentedon May 20, 2019
@FrankM1 and @Zertz When you upload an application, you should be specifying your dependencies in a
composer.jsonfile. WhenComposerruns, it will automatically create thevendordirectories.The ignored action is best practice, as you shouldn't be committing your
vendordirectories. It only ignores the instances of the dependencies you have locally installed in your system; only so that when you commit the codebase to AppEngine, it triggers to create its own set of dependencies. In that process, thevendordirectories should be recreated from the source, and you'd end up with the same system.So for clarity, the local dependencies don't get transferred but essentially get recreated by AppEngine.
@Zertz
@FrankM1
You can install plugins through Composer package; although not every plugin is available. You can check on Packagist, if the plugin is available as a Composer package. You also need to make sure that the plugin is listed properly in the
composer.json. Unfortunately, though there isn't a ready-made package for this plugin yet, but there are packages for other GCS plugins that accomplish the same thing. If you're set on using this particular plugin though, there are a few workarounds for installing plugins that aren't packaged yet, such as https://stackoverflow.com/questions/16847994/how-do-you-get-composer-to-install-a-non-composer-package.Hope that helped! 🤙
FrankM1 commentedon May 21, 2019
Thank you @ran-dall This indeed does clarify a few points for me. 90% of plugins I deploy to app engine are in private repos. I'll need to figure out how to add those using composer. What you describe does make sense.
wsnel commentedon Apr 18, 2020
For me, the following worked for a GCE image (via GCP marketplace):
ssh into the image, using console
sudo apt-get install git
cd ~
git clone https://github.com/GoogleCloudPlatform/wordpress-plugins.git
cd wordpress-plugins/gcs-media-plugin
sudo apt-get install composer
composer install
cd ~
sudo cp -r wordpress-plugins/gcs-media-plugin /var/www/html/wp-content/plugins/
sudo chown -R www-data.www-data /var/www/html/wp-content/plugins/gcs-media-plugin