Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to read file from location issue #171

Closed
PhilippeGauthier opened this issue Oct 13, 2022 · 7 comments · Fixed by #174
Closed

Unable to read file from location issue #171

PhilippeGauthier opened this issue Oct 13, 2022 · 7 comments · Fixed by #174

Comments

@PhilippeGauthier
Copy link

This is probably something on my end but I'm getting an error where if I turn SAVE_CACHED_IMAGES to false I get the following error:

Unable to read file from location: containers/assets/img/...file.jpg.

I ran php please responsive:regenerate previously and can confirm that the file that's throwing the error does exist. I'm wondering if the addon should be referencing img/containers/assets/img/...file.jpg instead? In assets.php I've got 'cache_path' => public_path('img'), so I'd think that would resolve that?

Thanks for your help!

final class UnableToReadFile extends RuntimeException implements FilesystemOperationFailed

{

    /**

     * @var string

     */

    private $location = '';



    /**

     * @var string

     */

    private $reason = '';



    public static function fromLocation(string $location, string $reason = '', Throwable $previous = null): UnableToReadFile

    {

        $e = new static(rtrim("Unable to read file from location: {$location}. {$reason}"), 0, $previous);

        $e->location = $location;

        $e->reason = $reason;



        return $e;

    }



    public function operation(): string

    {

        return FilesystemOperationFailed::OPERATION_READ;

    }



    public function reason(): string

    {

        return $this->reason;
@ncla
Copy link
Collaborator

ncla commented Oct 14, 2022

Hi,

Please provide full error stack trace, you only provided the exception class.

What exactly is SAVE_CACHED_IMAGES? I see no mention of this in statamic/cms. Are you referring to assets.php config file setting image_manipulation.cache?

Is this in SSG environment? This might be a core issue. See: statamic/ssg#110

Could you please provide a step by step reproduction for this bug? It is not clear how to reproduce this yet from the initial description. Would help speed up resolving this issue a lot.

@PhilippeGauthier
Copy link
Author

PhilippeGauthier commented Oct 14, 2022

Sorry - yes the SAVE_CACHED_IMAGES a setting that the Peak addon creates. It's an alias to the image_manipulation.cache setting. Setting it to false creates these errors while setting it to true seems to alleviate them.

It is not in SSG environment. Static caching is set to null.

Here's the full stack trace:

https://flareapp.io/share/V7j19EnP#F130

I ran the php please responsive:regenerate because this was an existing project with a ton of images. If I upload an image from the CP errors don't occur on that particular image. I've tried using generic tags like {{ responsive:hero_image }} and {{ responsive:hero_image glide:width="1600" }} and both throw errors.

Do you need any other info? Thanks for your response!

@ncla
Copy link
Collaborator

ncla commented Oct 14, 2022

When you are stuck with this kind of error try running php please glide:clear, that should "solve" it I think. But I am still curious how you got here in first place to that error, as responsive:regenerate command will not execute if image_manipulation.cache is false.

@ncla
Copy link
Collaborator

ncla commented Oct 14, 2022

Nevermind, I just tried this myself. Simply set image_manipulation.cache to true, ran php please responsive:generate, refreshed a page with responsive tag and got the same error. I think key thing is that when you toggle cache, it gets confused.

That will do for now, bug confirmed.

@ncla
Copy link
Collaborator

ncla commented Oct 16, 2022

So looking into this a bit deeper, as long as you do not switch cache setting many times and just leave it one value - it should be fine.

I agree that this is not very pleasant and is a misleading experience though.

To get out of this error, after you have changed cache value, do php please glide:clear.

If it happens anyway without changing cache settings, for now you can disable placeholder generation by setting tag parameter placeholder="false".

@ncla ncla closed this as completed in #174 Oct 16, 2022
@ncla
Copy link
Collaborator

ncla commented Oct 16, 2022

Hey,

I found a workaround fix and published it in v2.14.2.

Let me know if you are still having trouble with this.

@PhilippeGauthier
Copy link
Author

Works great. Thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants