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

Composer installation not working - fatal error upon attempting activation #893

Closed
4 tasks done
blakmarkit opened this issue Apr 16, 2024 · 8 comments
Closed
4 tasks done

Comments

@blakmarkit
Copy link

Checklist

  • I have looked into the Readme and the documentation, and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

Considering how arduous it has been to troubleshoot this issue, it would be nice if there was an actual released 5.x zip package here on the repo or on the WP plugins repo. There's been many issues over the last year and half asking for a release, with promises that it would be "coming soon" or within "weeks".

#863 (comment)
#889
#859 (comment)

Could someone assist me in configuring this correctly? If you need any other info, please let me know.

stack trace (on Local):

PHP Fatal error:  Uncaught Error: Class "Auth0\WordPress\Plugin" not found in C:\Users\<user>\Local Sites\<site>\app\public\wp-content\plugins\wordpress\wpAuth0.php:84
Stack trace:
#0 C:\Users\<user>\Local Sites\<site>\app\public\wp-content\plugins\wordpress\wpAuth0.php(68): wpAuth0()
#1 C:\Users\<user>\Local Sites\<site>\app\public\wp-admin\includes\plugin.php(2389): include_once('C:\\Users\\dreadn...')
#2 C:\Users\<user>\Local Sites\<site>\app\public\wp-admin\plugins.php(194): plugin_sandbox_scrape('wordpress/wpAut...')
#3 {main} thrown in C:\Users\<user>\Local Sites\<site>\app\public\wp-content\plugins\wordpress\wpAuth0.php on line 84

composer.json is configured at the root of the WP directory. This is a requirement for our host—they do not support a Bedrock structure. Attempting to run composer require from either wp-content or wp-content/plugins doesn't work—no directory is created.

composer config:

{
    "name": "site/site",
    "description": "description",
    "repositories": {
        "composer.<site>.com": {
            "type": "composer",
            "url": "https://composer.<site>.com/"
        },
        "wpackagist": {
            "type": "composer",
            "url": "https://wpackagist.org",
            "only": [
                "wpackagist-plugin/*",
                "wpackagist-theme/*"
            ]
        },
        "git/<repo>": {
            "type": "vcs",
            "url": "[email protected]:<site>/<repo>.git"
        }
    },
    "require": {
        "auth0/wordpress": "^5.2",
        "bricks/bricks": "^1.8",
        "nyholm/psr7": "^1.8",
        "symfony/http-client": "^7.0",
        "wpackagist-plugin/members": "^3.2",
        "wpackagist-plugin/query-monitor": "^3.13"
    },
    "autoload": {
        "psr-0": {
            "<site>": "src/"
        }
    },
    "extra": {
        "installer-paths": {
            "wp-content/plugins/{$name}/": [
                "type:wordpress-plugin"
            ],
            "wp-content/themes/{$name}/": [
                "type:wordpress-theme"
            ]
        }
    },
    "config": {
        "allow-plugins": {
            "composer/installers": true,
            "php-http/discovery": true
        },
        "vendor-dir": "lib/vendor",
        "sort-packages": true
    }
}

Reproduction

run composer require symfony/http-client nyholm/psr7 auth0/wordpress

  • with and without version constraints
  • with and without dependencies
  • run as just composer require auth0/wordpress
  • from root directory /, wp-content, wp-content/plugins

Upon activating the 5.2 version of the plugin, installed via composer, I get a fatal error.

Additional context

No response

wp-auth0 version

5.2

WordPress version

6.5.2

PHP version

8.2.x

@blakmarkit
Copy link
Author

After much struggle, I was able to find a workaround for my workflow—I'm not able to directly include this in my site's composer.json. Instead I needed to download it separately and run the composer require incantation. Once that was done, I cleaned up the directory and zipped it. I was then able to serve it as a package via my private composer repo.

I'm not sure if I consider this closed, as the underlying issue is a lack of a pre-built package being available either here on GitHub or via the WP plugins repo.

@chadevans
Copy link

@blakmarkit happened to come across your issue because I'm interested in the other open issue. Brings a few questions to mind.

  1. Are you able to add other packages? Like composer require wpackagist-plugin/wordpress-seo
  2. From the error, does the file actually exist at C:\Users\<user>\Local Sites\<site>\app\public\wp-content\plugins\wordpress\wpAuth0.php?
  3. Will the "download separately" method be able to require all the required packages, and the required dev packages? (See image below)
image

Also curious your local development environment and your host. I'm using a Bedrock setup with lots of other plugins and didn't run into any issues installing with composer require auth0/wordpress.

@blakmarkit
Copy link
Author

@chadevans my site structure (local and host) is standard WP, not Bedrock, because of my host. My composer.json is at the root of the WP directory, along with my vendor directory, which is where I believe the problem is happening. The plugin is expecting the vendor directory to be inside the auth0 plugin folder itself. The file from the fatal error does exist in that path, but I believe it was failing because somewhere in the call stack it's trying to find the auth0/auth0-php dependency, which is not in the vendor directory within the plugin's directory (it's in the site root).

Other wpackagist packages are added to my main composer.json without an issue. I'm also pulling in a variety of git repos, as well as using a private self-hosted composer repo for securely serving paid plugins.

In this case, I downloaded the 5.2 release source separately composer require symfony/http-client nyholm/psr7 auth0/wordpress, ran composer install --no-dev inside that directory, then cleaned and zipped it to be served (as a zip) by my self-hosted composer repo.

So the problem is at least partially that the directions aren't clear on adapting for non-Bedrock installations, and partially that this is even necessary given that auth0 could finally package zip releases.

@chadevans
Copy link

@blakmarkit looks like you have solid troubleshooting skills. I will add that in a Bedrock install, the vendor folder and composer.json are in the root directory, not the plugin folder. Composer commands are run from root. Here are the contents of the installed auth0/wordpress plugin:

image

Inside the root vendor folder, it installs like this:

image

@blakmarkit
Copy link
Author

@chadevans interesting! No idea why it wasn't picking up the dependencies for me. They were in the root, but the plugin wasn't finding them. Mine only worked once the vendor directory was inside the same folder with wpAuth0.php.

@chadevans
Copy link

Comparing our two composer.json files, in the "config" section, mine reads "vendor-dir":"vendor" and yours has "vendor-dir":"lib/vendor". Maybe try changing to "vendor" if it wasn't creating a lib/vendor folder? That's all I can think of to try.

@evansims
Copy link
Member

evansims commented Apr 19, 2024

Considering how arduous it has been to troubleshoot this issue, it would be nice if there was an actual released 5.x zip package here on the repo or on the WP plugins repo.

All 5.x releases are available here, under the "releases" tab: https://github.com/auth0/wordpress/releases. Just expand the "assets" to get the ZIP downloads. We recommend the Composer approach because it guarantees all dependencies are installed with their latest versions (security fixes, etc.), and additional steps are necessary to make the ZIP approach work.

There's been many issues over the last year and half asking for a release, with promises that it would be "coming soon" or within "weeks".

Respectfully, two of the three links you shared are for v4 of the plugin and have no relation to the version we're discussing here. I appreciate that you created this issue, but I must ask, please do not ping years-old issues; it isn't polite to other users. Thanks very much.

After much struggle, I was able to find a workaround for my workflow—I'm not able to directly include this in my site's composer.json. Instead I needed to download it separately and run the composer require incantation. Once that was done, I cleaned up the directory and zipped it. I was then able to serve it as a package via my private composer repo.

I'm glad you could troubleshoot and chart an installation path that worked for your environment. I appreciate your feedback, and I'll definitely consider this for future updates, but we are not planning any imminent changes to our distribution approach for the plugin at this time. I will close since a resolution was found, but please feel free to continue the discussion.

@mattjric
Copy link

mattjric commented May 8, 2024

Thanks for the great writeup - can I suggest adding a summary to this issue to explain how to workaround for non Bedrock deployment. To get the plugin to show and successfully activate in the /wp-admin/plugins.php page on a virgin WordPress 6.5.3 install using composer I had to:

cd ./wp-content/plugins/
composer require symfony/http-client nyholm/psr7 auth0/wordpress:^5.0
mkdir ./auth0
cp -r ./vendor/auth0/wordpress/* ./auth0/
mv ./vendor/ ./auth0/vendor/

I tried to then delete the ./auth0/vendor/auth0 folder but then I got fatal error again when trying to activate - so not sure what the reason is but it worked.

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