Magento 2.1.4 – Fix Readiness Check Failure Due to Cron and Gitignore Not Writable

magento-2.1

I have a Magento 2.1.4 community site that is failing the readiness check to be able to install an extension via Magento Marketplace.

Normally we install extensions by downloading the zip file and installing via FTP or SSH and doing everything from the command line. But we want to make sure that it's easy for a client to install something via the Magento Marketplace.

I was able to get to this step in the readiness check, but it's saying that the Cron script is not installed / not ready. Here's a screenshot:
Magento 2.1.4 fails readiness check due to cron

The error is a non-writable path to the .gitignore file (although the file exists and it is writable).

I saw a write up on GitHub about making a core modification to the setup script. However, I'd rather solve the issue if possible.

Best Answer

Most likely the issue here is two fold. One is the file ownership on the site you are trying to install on and the other the cron settings itself for the server that is hosting the site.

Permissions and ownership issue with Magento 2 is like cilantro, depending on the server your site is installed on, you either barely notice that it's there or it taste like a mouth full of soap.

If the cron wasn't running, you would get the warning that Abhishek Panchal pointed to:

Cron script readiness check failed.

Error from Setup Application Cron Script: Cron job has not been configured yet Other checks will fail as a result (PHP version, PHP settings, and PHP extensions)

Error from Updater Application Cron Script: Cron job has not been configured yet

Which can be solved with this post Error : cron job has not been configured yet

But that isn't the issue here. Your error is:

Error from Updater Application Cron Script:

Found non-writable path(s): ect.....

What is tricky here is the file the error is pointing to might even be writable, and changing the file permissions/ownership wont help you clear the error. When i came across this very error on a dev site, the issue was the cron had been set up using the root user on the server. We have a bunch of different users on our dev server, and anyone of us can create a cron job. But if your cron was set up using root and not the user where the dev site is being served, when Magento scans the site, it wont see that the correct cron is configured and will fail to have write permission when you try and install an extension.

Even more frustrating is that your cron might even be working correctly as root. But the dead give-a-way is when you check in the var/ directory after trying to install the extension. For our dev sites, many of the directories would have ownership what would match the user that had created the cron. So if the user for the dev site was pickles, instead of the owner being pickles:www-data it was root:root. You can find this out by moving into the var folder and running ls -la.

enter image description here

So if the ownership of the cron is wrong, you can log in as whatever user is showing up incorrectly using sudo su {user_name} and running the crontab -e commend in the terminal. You should see something like this:

*/1 * * * * php /{path/to/your/site}/bin/magento cron:run
*/1 * * * * php /{path/to/your/site}/update/cron.php
*/1 * * * * php /{path/to/your/site}/bin/magento setup:cron:run

If that is the case, you need to cut this text out of the crontab, log in as the user that the dev site is serving up the site from and paste it into that crontab.

But we aren't done yet!!! Once the correct crontab user is set up, you still need to set the correct ownership for your whole Magento site. So in the root of the site run:

sudo chown -R pickles:www-data *

And you should be good to go. Of course you might be running into slightly different issues depending on the server OS and if it's running apache or not. But the basic concepts are all that same.

Related Topic