0
Magento 2.4.2-p1
Smartwave Porto theme
extensions from Amasty

We have the Smartwave Porto theme. It came with Mageplaza Layered Navigation but an old version. Since we have some problems that I raised with Smartwave Porto, they suggested I would upgrade to the latest Mageplaza Layered Navigation version = layered-navigation_v4.1.1_m2_ce_mageplaza.

I have done that, and when running the following command afterwards:

php bin/magento setup:di:compile

I get this Error:

The directory "/home/myaccount/public_html/generated/code/Magento" cannot be deleted Warning!rmdir(/home/myaccount/public_html/generated/code/Magento): Directory not empty

I asked Mageplaza and said the following:

...please run the command again with adding "sudo" at first.

So I've tried the following:

sudo php bin/magento setup:di:compile

and my Putty says the following:

We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

and asked for the password again. Once I entered the password - it gave the following Error:

myaccount is not in the sudoers file. This incident will be reported.

When googling this topic, I found the following article:

https://stackoverflow.com/questions/52644737/i-cant-delete-the-folder-generated-code-in-magento-2-2-6

Here it says:

www-data must be owner of the project if using Apache as web-server. Please execute commands given below:

sudo chown -R www-data:www-data [path to magento directory]
navigate to root of your magento project
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod u+x bin/magento

We had a problem with ownership/permissions before. Is it safe for me run these in Putty via SSH on the account itself and/or ask our hosting company to do it for me?

asked Oct 18, 2021 at 19:42

3 Answers 3

2

You can run the command like this one :

sudo chmod -R 777 var/ generated/ pub/
php bin/magento setup:di:compile
answered Oct 19, 2021 at 5:00
1
  • This works for me. Thank you. Commented Oct 21, 2021 at 5:16
1

It's worth checking with your web host to see if the file permissions are set up correctly, however you should try to clear the generated/code directory first. Try clearing the directory manually before running the compile command:

rm -r generated/code/*
php bin/magento setup:di:compile

You can refer to the devdocs for more information about clearing directories during development: https://devdocs.magento.com/guides/v2.4/howdoi/php/php_clear-dirs.html

answered Oct 18, 2021 at 23:55
1
  • This is a good solution but appears to be temporary as di:compile worked immediately after but the problem reappeared the next day. Commented Oct 21, 2021 at 5:16
0

Should Change the folder permissions on own via chmod and chown

answered Oct 25, 2021 at 2:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.