roots / sage

WordPress starter theme with Laravel Blade components and templates, Tailwind CSS, and a modern development workflow
https://roots.io/sage/
MIT License
12.71k stars 3.06k forks source link

Bug: Writing to a non-writable environment #3110

Closed travisanderson99 closed 1 year ago

travisanderson99 commented 1 year ago

Terms

Description

What's wrong?

We have recently migrated to Wordpress VIP (https://wpvip.com) for our host, and they have a read-only platform. Sage attempts to create directories in certain cases, which throws the following error:

Read-only file system in /chroot/var/www/wp-content/themes/mytheme/vendor/illuminate/filesystem/Filesystem.php

This is the block of code where the error is occurring:

    public function makeDirectory($path, $mode = 0755, $recursive = false, $force = false)
    {
        if ($force) {
            return @mkdir($path, $mode, $recursive);
        }

        return mkdir($path, $mode, $recursive);
    }

Possible solutions

Checking to see if the directory is writable would avoid this issue on non-writable systems such as ours.

Temporary workarounds

The site still functions as expected using the Sage theme, but these warnings are being thrown on every request.

Steps To Reproduce

  1. Visit any site within our multisite network such as https://www.prepredzone.com, which will trigger the error internally.

Expected Behavior

Ideally, the filesystem would only attempt to create the directory if the directory is writable or can be written to.

Actual Behavior

An error is generated when the directory is attempted to be created.

Relevant Log Output

No response

Versions

10.0.3

retlehs commented 1 year ago

Hi @travisanderson99! We use our forum for support requests, not GitHub issues. The code block that you highlighted comes from our dependencies and isn't something that we can modify.

I think this is the first we've heard of an issue with WP VIP, but the solution to this problem should be similar to how folks are deploying Sage 10 sites with Pantheon (search our forum for more info).

Furthermore, since you're a WP VIP customer and paying for their services, I'd suggest first reaching out to their support folks to see if they've already got an answer for you. They can also reach out to us directly if they have any questions.

travisanderson99 commented 1 year ago

Hi Ben, thanks for the reply. I realized after I created this ticket last night that the Illuminate/Filesystem package isn't something you manage.

I was able to fork that repository and modify the function that attempts to write to a directory and then pass that updated package to composer. That seems to have resolved the issue.