markshust / docker-magento

Mark Shust's Docker Configuration for Magento
https://m.academy/courses/set-up-magento-2-development-environment-docker/
MIT License
2.57k stars 1.01k forks source link

Missing write permissions #80

Closed avremel closed 6 years ago

avremel commented 6 years ago

So I reinstalled everything from repo.

When I do ./bin/setup I get the following errors


  [Exception]                                        
  Missing write permissions to the following paths:  
  /var/www/html/var/composer_home/composer.lock      
  /var/www/html/var/composer_home/cache              
  /var/www/html/var/composer_home/vendor             
  /var/www/html/var/composer_home/.htaccess     

and many of these

chmod: changing permissions of 'var/composer_home/vendor/symfony/polyfill-mbstring/Mbstring.php': Operation not permitted
chmod: changing permissions of 'var/composer_home/vendor/symfony/polyfill-mbstring/bootstrap.php': Operation not permitted
chmod: changing permissions of 'var/composer_home/vendor/symfony/polyfill-mbstring/README.md': Operation not permitted

and this


  [Symfony\Component\Console\Exception\CommandNotFoundException]  
  There are no commands defined in the "deploy:mode" namespace.   

  [Symfony\Component\Console\Exception\CommandNotFoundException]  
  There are no commands defined in the "indexer" namespace.       
markshust commented 6 years ago

@avremel can you try doing a: ./bin/fixperms ?

markshust commented 6 years ago

can you please also paste the full output of ./bin/setup --- that may help me debug

avremel commented 6 years ago

Thanks for being so responsive!

Link to errors

./bin/fixperms gives same errors (showing the beginning and tail end):

Correcting filesystem permissions...
chown: changing ownership of '/var/www/html/var/composer_home/composer.lock': Operation not permitted
chmod: changing permissions of 'var/composer_home/vendor/laravel/installer/src': Operation not permitted
Filesystem permissions corrected.
markshust commented 6 years ago

that is really odd error. try doing this:

./bin/cli chown -R app:app /var/www

then after that, try running ./bin/fixperms again? i think something was laying around from your previous install. but this should fix.

avremel commented 6 years ago

Still doesn't work, even after docker system prune -a --volumes and running all commands.

FWIW, magento shows this error: screen shot 2018-01-15 at 6 04 11 pm

markshust commented 6 years ago

hmm. In mean time you can just do: ./bin/cli chmod -R 777 var On Mon, Jan 15, 2018 at 6:09 PM Avremel Kaminetzky notifications@github.com wrote:

Still doesn't work, even after docker system prune -a and running all commands.

FWIW, magento shows this error: [image: screen shot 2018-01-15 at 6 04 11 pm] https://user-images.githubusercontent.com/10588097/34964982-e4c73e36-fa1e-11e7-9574-647635140837.png

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/markoshust/magento-docker/issues/80#issuecomment-357809364, or mute the thread https://github.com/notifications/unsubscribe-auth/AAarJWgS2P0vF9oJ5yatqv6dQgwpLyxEks5tK9qrgaJpZM4Re-6H .

avremel commented 6 years ago

Same errors on a fresh install (sample):

chmod: changing permissions of 'var/composer_home/composer.lock': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/config': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/objects': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/objects/9e': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/objects/9e/9dae087a729132bc21129c69683828298491ea': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/objects/3c': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/objects/3c/399a24b0bff15555cecffce0c7f337056ee927': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/objects/93': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/objects/93/2d6dca1482bb00919b3e3ceaab1950cea61714': Operation not permitted
chmod: changing permissions of 'var/composer_home/cache/vcs/https---github.com-klaviyo-php-klaviyo.git/objects/5a': Operation not permitted
avremel commented 6 years ago

This worked for me:

Out of the container:

sudo rm -rf ./var/composer_home ./composer.lock ./vendor Inside the container:

mkdir /var/www/html/vendor/ composer install

I removed ./bin/fixperms from setup because it didn't recognize my file structure. Then I did chown -R app:app for anything required permissions that Magento requested

https://magento.stackexchange.com/a/209832/62779

markshust commented 6 years ago

great, glad to hear that fixed it. i'm assuming this was for an m2 install?

i'm actively supporting this repo again, so i'll try debugging this all again and fixing any issue related to permissions. in my experience none of this was happening and i didn't have any issues with permissions or ownerships... however i made a ton of changes in the last week and could have borked something.

avremel commented 6 years ago

It's a m2 install. Interesting enough, I had the same issue with https://github.com/clean-docker/Magento2

I was still having issues, so I created a fresh install, reinstalled composer, and ./bin/fixperms worked perfectly. Will report any new issues.

markshust commented 6 years ago

If you are on a Mac, ensure you are running the most recent version of Docker for Mac --

Version 17.12.0-ce-mac47 (21805)

On Thu, Jan 18, 2018 at 12:13 PM Avremel Kaminetzky < notifications@github.com> wrote:

It's a m2 install.

I actually began seeing more write errors post install, so I am scrapping everything and restarting. I am not sure why permissions reverted to no write access.

Interesting enough, I had the same issue with https://github.com/clean-docker/Magento2

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/markoshust/magento-docker/issues/80#issuecomment-358715770, or mute the thread https://github.com/notifications/unsubscribe-auth/AAarJcmd8dUKSKFMV4Nr66Q-sZiEIpgJks5tL3vLgaJpZM4Re-6H .

avremel commented 6 years ago

Running Version 17.12.0-ce-mac47 (21805).

I've retraced steps on my new install to capture my new permissions error.

  1. Admin -> System -> Cache
  2. Error: screen shot 2018-01-18 at 1 09 32 pm
  3. ./bin/fixperms
  4. Everything works

UPDATE Its seems every time I make a file edit or clear cache and Magento runs its scripts, the correct permissions are removed..

I've seen some talk about it but no good answer: https://magento.stackexchange.com/questions/170736/magento-2-1-6-file-permissions-keep-resetting-some-to-none https://github.com/magento/magento2/issues/2525

avremel commented 6 years ago

I added this to ./bin/fixperms based of this comment https://github.com/magento/magento2/issues/2525#issuecomment-159898476 and everything works!

./bin/cli find var vendor pub/static pub/media app/etc -type f -exec chmod g+s {} \;
./bin/cli find var vendor pub/static pub/media app/etc -type d -exec chmod g+s {} \;
markshust commented 6 years ago

Thank you. I'm going to reopen this ticket and leave it open until I investigate since a possible fix for a possible problem is here.

sajidunnar commented 6 years ago

@markoshust
I am into kind of same error , its fresh installation

$./bin/setup Correcting filesystem permissions... find: 'pub/static': No such file or directory find: 'pub/media': No such file or directory find: 'pub/static': No such file or directory find: 'pub/media': No such file or directory Filesystem permissions corrected. Turning on developer mode.. [Symfony\Component\Console\Exception\CommandNotFoundException] There are no commands defined in the "deploy:mode" namespace. [Symfony\Component\Console\Exception\CommandNotFoundException] There are no commands defined in the "indexer" namespace Then I went into container it self $ docker-compose exec phpfpm bash root@73b0435da591:/var/www/html# cd pub root@73b0435da591:/var/www/html/pub# ls cron.php errors get.php health_check.php index.php opt static.php root@73b0435da591:/var/www/html/pub#

Noticed no folders has been sync , I also removed pub/media and pub/static docker-sync.xml but still no help

sync_excludes: ['.idea', '.git*', 'pub/media', 'pub/static', 'var/cache', 'var/composer_home', 'var/page_cache', 'var/session', 'var/tmp', 'var/view_preprocessed']

markshust commented 6 years ago

ok, i ditched docker-sync. there is a much better way. the permissions have completely changed and are now set in the dockerfiles, this should take care of absolutely everything related to ownerships and permissions. they are building right now on dockerhub, please wait for the new images to complete building and you can retest. note the new readme, there is a very different docker-compose.yml file now and way of configuring. it's much simpler now. i'll close this out, but feel free to update here and/or reopen if you are still having problems. hope you like the new images :)

m1aw commented 6 years ago

I was having the same problems as above. And ./bin/fixperms didn't solve the issue for me.

So I logged onto the VM as root an ran:

root@ba4800228bec:/var/www/html#  find var vendor pub/static pub/media app/etc -type f -exec chmod g+s {} \;
root@ba4800228bec:/var/www/html# find var vendor pub/static pub/media app/etc -type d -exec chmod g+s {} \;
root@ba4800228bec:/var/www/html# chown -R app:app /var/www
root@ba4800228bec:/var/www/html#

After that I was able to finish ./bin/setup

MaryanShvets commented 1 month ago

I was having the same problems as above. And ./bin/fixperms didn't solve the issue for me.

but !!! ./bin/fixowns ./bin/fixperms

and after this ... ta dam ... Everything works

PS: @markshust thankyou for your great work