scaffold-command
scaffold-command copied to clipboard
Invalid theme slug specified. The target directory
I'm hitting this Invalid theme slug issue when I am running wp-cli from a different folder to the Wordpress installation.
My full command is:
./vendor/bin/wp scaffold child-theme child-testchild4 --path=../testchild4 --parent_theme='the-parent-theme' --theme_name='test child 4' --activate
The full error is: Error: Invalid theme slug specified. The target directory '/home/apweb/public_html/deploy/../testchild4/wp-content/themes/apb-evolve-testchild4' is not in '/home/apweb/public_html/deploy/../testchild4/wp-content/themes' I am running the command from the "deploy" folder, and my WP install is in ../testchild4.
The path: /home/apweb/public_html/deploy/../testchild4/wp-content/themes/apb-evolve-testchild4 Is certainly inside: /home/apweb/public_html/deploy/../testchild4/wp-content/themes
I traced the issue to Scaffold_Command.php in check_target_directory() and in this case $parent_dir is: /home/apweb/public_html/testchild4/wp-content/themes.
So the string match is failing, but it's the exact same folder. Wrapping the str_replace() path with realpath() fixes this issue.