Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

WP-CLI error installing plugins/themes. "Could not create directory". Permissions error? Ubuntu 14.04 x64 #1395

Closed
peterjohnjoseph opened this issue Mar 2, 2015 · 6 comments

Comments

@peterjohnjoseph
Copy link

Hey guys, I've been searching for hours trying to figure out a solution to this problem, but I've given up and its time to ask for some help.

I'm running Wordpress on an Ubuntu 14.04 x64 server. I use Mark Jaquith's WP-Skeleton folder set up, and have two shared folders set up; /var/www/wp (sitename/www/wp on the host) for Wordpress core files, and /var/www/content/ (sitename/www/content on the host) for a custom content directory which is the purpose of WP-Skeleton.

When SSH'ing into the VM and running WP-CLI, everything seems to work correctly as far as WP-CLI knowing the Path to my Content directory, and Wordpress core files. The problem is when trying to install plugins or themes, as shown below-

[07:20 PM]-[vagrant@packer-virtualbox-iso-1422601639]-[/var/www]-[git master]
$ wp plugin install jetpack
Installing Jetpack by WordPress.com (3.3.2)
Downloading install package from https://downloads.wordpress.org/plugin/jetpack.3.3.2.zip...
Unpacking the package...
Warning: Could not create directory.

My first, and only thought so far is that this is a permissions error, but with my limited knowledge of this area, I've only been able to do so much, however, I can say that I've tried changing the permissions of the Content directory to 755, then 765, and even 777 using chmod -v 755 /var/www/content/.

That also didn't work, even with the permissions set to 777. So what else could be wrong? I know this probably has to do with permissions for www-data, but like I said, I have limited knowledge of what to look for, or change. I'm sure this is something simple, and I'm sure this isn't directly related to WP-CLI, as I have a feeling if I used any other web app to try and install to the www folder that I'd have the same problem.

I'm going to include my config.yaml file below for completeness sake. If you need any other information from me, I'll be sure to include it.

Thanks in advance,
P.J.


---
vagrantfile-local:
    vm:
        box: puphpet/ubuntu1404-x64
        box_url: puphpet/ubuntu1404-x64
        hostname: ''
        memory: '512'
        cpus: '1'
        chosen_provider: virtualbox
        network:
            private_network: 192.168.56.101
            forwarded_port:
                FzsTy6yOA4TD:
                    host: '8220'
                    guest: '82'
        post_up_message: ''
        provider:
            virtualbox:
                modifyvm:
                    natdnshostresolver1: on
            vmware:
                numvcpus: 1
            parallels:
                cpus: 1
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: site.pp
                module_path: puphpet/puppet/modules
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            2qEylDqy8Swr:
                owner: www-data
                group: www-data
                source: ./www
                target: /var/www
                sync_type: nfs
                rsync:
                    args:
                        - '--verbose'
                        - '--archive'
                        - '-z'
                    exclude:
                        - .vagrant/
                    auto: 'false'
            T5OqRjLNSpNW:
                owner: www-data
                group: www-data
                source: ./www/shared
                target: /var/www/shared
                sync_type: nfs
                rsync:
                    auto: 'false'
        usable_port_range:
            start: 10200
            stop: 10500
    ssh:
        host: null
        port: null
        private_key_path: null
        username: vagrant
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
server:
    install: '1'
    packages:
        - vim
        - htop
        - curl
        - git
        - vsftpd
        - phpmyadmin
        - imagemagick
        - ack-grep
        - ngrep
        - mysql-client
users_groups:
    install: '1'
    groups: {  }
    users: {  }
cron:
    install: '1'
    jobs: {  }
firewall:
    install: '1'
    rules: null
apache:
    install: 0
    settings:
        user: www-data
        group: www-data
        default_vhost: true
        manage_user: false
        manage_group: false
        sendfile: 0
    modules:
        - rewrite
    vhosts:
        42vlikdkfgdu:
            servername: awesome.dev
            serveraliases:
                - www.awesome.dev
            docroot: /var/www/awesome
            port: '80'
            setenv:
                - 'APP_ENV dev'
            directories:
                pvg0rcqmuxg8:
                    provider: directory
                    path: /var/www/awesome
                    options:
                        - Indexes
                        - FollowSymlinks
                        - MultiViews
                    allow_override:
                        - All
                    require:
                        - all
                        - granted
                    custom_fragment: ''
            engine: php
            custom_fragment: ''
            ssl_cert: ''
            ssl_key: ''
            ssl_chain: ''
            ssl_certs_dir: ''
    mod_pagespeed: 0
nginx:
    install: '1'
    settings:
        default_vhost: 1
        proxy_buffer_size: 128k
        proxy_buffers: '4 256k'
    upstreams: {  }
    vhosts:
        muuruopw9i98:
            proxy: ''
            server_name: peterjohnjoseph.dev
            server_aliases:
                - www.peterjohnjoseph.dev
            www_root: /var/www/
            listen_port: '80'
            location: \.php$
            index_files:
                - index.html
                - index.htm
                - index.php
            envvars:
                - 'APP_ENV dev'
            engine: php
            client_max_body_size: 1m
            ssl_cert: ''
            ssl_key: ''
php:
    install: '1'
    version: '56'
    composer: '1'
    composer_home: ''
    modules:
        php:
            - cli
            - intl
            - mcrypt
            - memcached
            - gd
            - imagick
            - common
            - imap
            - memcache
            - fpm
            - mysql
            - curl
        pear:
            - PHP_CodeSniffer
        pecl:
            - pecl_http
            - ZendOpcache
    ini:
        display_errors: On
        error_reporting: '-1'
        session.save_path: /var/lib/php/session
    timezone: America/Chicago
    mod_php: 0
hhvm:
    install: '0'
    nightly: 0
    composer: '1'
    composer_home: ''
    settings:
        host: 127.0.0.1
        port: '9000'
    ini:
        display_errors: On
        error_reporting: '-1'
    timezone: null
xdebug:
    install: '1'
    settings:
        xdebug.default_enable: '1'
        xdebug.remote_autostart: '0'
        xdebug.remote_connect_back: '1'
        xdebug.remote_enable: '1'
        xdebug.remote_handler: dbgp
        xdebug.remote_port: '9000'
        xdebug.idekey: phpstorm1
xhprof:
    install: '0'
wpcli:
    install: '1'
    version: v0.17.1
drush:
    install: '0'
    version: 6.3.0
ruby:
    install: '1'
    versions:
        3Q9R9NNOgcs0:
            default: '1'
            version: 2.1.2
            gems:
                - sass
                - capistrano
                - capistrano-ext
                - capistrano-grunt
                - capistrano-wpcli
            bundler: '1'
nodejs:
    install: '1'
    npm_packages:
        - grunt
        - grunt-cli
        - bower
python:
    install: '1'
    packages: {  }
    versions:
        1uAr8TaxGJqU:
            version: ''
mysql:
    install: '1'
    override_options: {  }
    root_password: '123'
    adminer: 0
    databases:
        0Wza8YHl1ivy:
            grant:
                - ALL
            name: pjj_dev
            host: localhost
            user: dbuser
            password: '123'
            sql_file: ''
postgresql:
    install: '0'
    settings:
        root_password: '123'
        user_group: postgres
        encoding: UTF8
        version: '9.3'
    databases: {  }
    adminer: 0
mariadb:
    install: '0'
    override_options: {  }
    root_password: '123'
    adminer: 0
    databases: {  }
    version: '10.0'
sqlite:
    install: '0'
    adminer: 0
    databases: {  }
mongodb:
    install: '0'
    settings:
        auth: 1
        port: '27017'
    databases: {  }
redis:
    install: '0'
    settings:
        conf_port: '6379'
mailcatcher:
    install: '0'
    settings:
        smtp_ip: 0.0.0.0
        smtp_port: 1025
        http_ip: 0.0.0.0
        http_port: '1080'
        mailcatcher_path: /usr/local/rvm/wrappers/default
        from_email_method: inline
beanstalkd:
    install: '0'
    settings:
        listenaddress: 0.0.0.0
        listenport: '13000'
        maxjobsize: '65535'
        maxconnections: '1024'
        binlogdir: /var/lib/beanstalkd/binlog
        binlogfsync: null
        binlogsize: '10485760'
    beanstalk_console: 0
    binlogdir: /var/lib/beanstalkd/binlog
rabbitmq:
    install: '0'
    settings:
        port: '5672'
elastic_search:
    install: '0'
    settings:
        version: 1.4.1
        java_install: true
solr:
    install: '0'
    settings:
        version: 4.10.2
        port: '8984'

@peterjohnjoseph
Copy link
Author

Just an update-

I solved the problem, temporarily, however, I'm hoping there is a better way.

So, basically I'm using the --allow-root flag on all of my commands so that I can use sudo to run the commands as the root user. So basically a command looks like sudo wp plugin install jetpack --allow-root

Like I said, if anyone has an easier way to handle this, I'd love to know.

I did find this, https://www.digitalocean.com/community/tutorials/how-to-use-puppet-to-manage-wordpress-themes-and-plugins-on-ubuntu-14-04 which details how I would install WP-CLI with Puppet normally, however, since it is already installed, there is one part of that that could help my situation, and its in the "resource.pp" file that he creates to say $user=root and another line of code to denote the --allow-root flag. Is there any place I could enter this code? I'm not sure how I would go about doing it by looking through the configuartion as is, as Puphpet is not set up like a typical Puppet based vm.

@jasperf
Copy link

jasperf commented Mar 15, 2015

Had the same issue just now on a local OSX server.

wp --debug plugin install redux-developer-mode-disabler
Installing Redux Developer Mode Disabler (1.0.0)
Downloading install package from https://downloads.wordpress.org/plugin/redux-developer-mode-disabler.1.0.0.zip...
Using cached file '/Users/jasper/.wp-cli/cache/plugin/redux-developer-mode-disabler-1.0.0.zip'...
Unpacking the package...
Warning: Could not create directory

all files and folders are _www:_www and directories are 755 and files 644 so why can't the directory be created? Adding my own user to _www group did not help either. --allow-root does work, but yeah that should not be needed..

@jtreminio
Copy link
Member

@peterjohnjoseph Just tried this, working fine after latest permissions updates to Vagrantfile.

I did change one thing, though. The www_root to peterjohnjoseph.dev should not be /var/www. I changed it to /var/www/peterjohnjoseph.dev.

/var/www should be the directory that contains multiple project directories, not a project itself.

@jasperf You need to run wp-cli from within the VM itself. I don't support OSX Server.

@peterjohnjoseph
Copy link
Author

Thank you, jtreminio. I'm not sure you realize how much your work is appreciated.

@pscott-au
Copy link

also be sure to check the permissions on the wp-content-upgrade directory

@harry-wood
Copy link

you mean wp-content/upgrade. That's useful thanks. I found I could change ownership of that one directory, run wp-cli core and plugin updates, and then change it back again. It's a shame the wp-cli error message doesn't state where it's trying to create a directory.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants