Error “could not delete” with Composer on Vagrant

前端 未结 16 1136
闹比i
闹比i 2020-12-14 05:45

I have a Vagrant running Linux and I\'m trying to install Symfony.

After the command composer create-project symfony/framework-standard-edition ./ \"2.5.*\"

16条回答
  •  渐次进展
    2020-12-14 06:29

    Just got the same issue.

    I see the problem in accessing to some local files. In my case target directory was under "root" and I'm not the root user.

    Solution

    Change permissions/owner of your files/directory.

    1. Redefine owner:

      sudo chown myuser:myuser -R /path/to

    2. Maybe there is some lack of permissions for group which you are in.
      So, try to run:

      sudo chmod g+rwX -R /path/to

    Or maybe you may run your command with "sudo" if it works for you (not recommended). :)

    P.S. Never use 777. It's not secure.

    UPD1

    Another thing, you may found out useful to solve the root of the cause, to wrap up your composer binary to run it always behalf a certain user.

    $ cat /usr/local/bin/composer
    #!/bin/bash
    
    # run composer behalf www-data user
    
    set -o pipefail
    set -o errexit
    set -o nounset
    #set -o xtrace
    
    [[ "${DEBUG:-}" = "true" ]] && set -o xtrace || true
    
    composer_debug=$([[ 'true' != "${COMPOSER_DEBUG:-}" ]] || echo '-vvv' )
    
    sudo -u www-data -- /usr/bin/composer ${composer_debug:-} $@
    

提交回复
热议问题