Closed davemcnally closed 4 years ago
Hi @davemcnally! I ran your code and noticed that johnpbloch/wordpress
is installed at the very end. It overwrites the build
folder where ACF Pro has been successfully installed just milliseconds ago. When you remove the johnpbloch/wordpress
package from the composer.json
and composer.lock
, ACF Pro gets installed at the first attempt.
Have a look at the way Bedrock configures WordPress: https://roots.io/bedrock/. They separate the wp-content
folder from the wordpress-install-dir
and thus avoid this problem.
Thanks, @ffraenz! That's an interesting issue… I wonder what the best approach is going to be moving forward to automate this process whilst keeping the directory structure as-intended. The issue only seems to be happening with ACF plugin — I have a bunch of other plugins also being loaded in which were just edited out for space and those install into build/wp-content/plugins
just fine:
"require": {
"johnpbloch/wordpress": ">=5.0",
"wpackagist-plugin/all-in-one-wp-security-and-firewall": "*",
"wpackagist-plugin/capability-manager-enhanced": "*",
"wpackagist-plugin/custom-post-type-ui": "*",
"wpackagist-plugin/duplicate-post": "*",
"wpackagist-plugin/mainwp-child": "*",
"wpackagist-plugin/restrict-widgets": "*",
"wpackagist-plugin/simple-301-redirects": "*",
"wpackagist-plugin/widget-css-classes": "*",
"wpackagist-plugin/wordpress-seo": "*",
"advanced-custom-fields/advanced-custom-fields-pro": "*"
},
Wonder what the difference is with ACF? For now, I may just write an alias
to run composer install
with plugins going into their own directory and then just automatically move them after install — unless you'd suggest another option to enable automating install whilst still keeping wp-content
within wordpress-install-dir
?
As temporary workaround, if I keep a composer.lock
file present, that allows me to run a post-install-cmd
to require ACF:
"scripts": {
"post-install-cmd": "composer require advanced-custom-fields/advanced-custom-fields-pro:*"
}
I had the exact same issue. prefer-stable: true
helped.
Furthermore, in my case, I was using https://github.com/gtap-dev/gravityforms-composer-installer too, which is heavily inspired by ffraenz/private-composer-installer
. Perhaps the two of them together might cause the aforementioned issue.
Furthermore, in my case, I was using https://github.com/gtap-dev/gravityforms-composer-installer too, which is heavily inspired by
ffraenz/private-composer-installer
.
@Luc45 I'm having this same issue, ACF + GF but prefer-stable
appears to have done nothing for me. Any idea why that fixed it for you?
Proper solution is simple:
{
"type": "package",
"package": {
"name": "advanced-custom-fields/advanced-custom-fields-pro",
"version": "5.7.13",
"type": "wordpress-plugin",
"dist": {
"type": "zip",
"url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%ACF_PRO_KEY}&t={%VERSION}"
},
"require": {
"johnpbloch/wordpress" : "^5.0.0",
"composer/installers": "^1.4",
"ffraenz/private-composer-installer": "^4.0"
}
}
}
What is done here? Adding to require "johnpbloch/wordpress" is changing order. As ACF need wordpress then this is by default proper coded ;) Add note to main Readme about order of installation.
@Triloworld Doesn't WordPress replace the entire plugin folder when you update it through Composer later on?
I'd recommend not to nest dependencies inside of each other. WordPress offers custom wp-content
locations making this a viable option. I'm closing this issue.
I just switched over to using this instead of @PhilippBaschke's version but I'm running into the same strange issue. I need to run
composer install
twice for ACF to install inside of the plugins directory as required. Here's an edited sample of mycomposer.json
file:Am I doing something wrong which is triggering the need to
composer install
twice?