TransWikia.com

Invalid Configuration Error in Craft CMS 3 using Nitro 2

Craft CMS Asked by cbad on June 16, 2021

I’m getting into Nitro 2 and so far loving it. I decided to create a scaffolding project to jump start other projects. Along the way, I ran into this error:

Invalid Configuration – yiibaseInvalidConfigException
/Users/cbad/websites/nitro/core/cms/web/cpresources doesn’t exist or isn’t writable by PHP.

The path exists and the permissions, look correct. They are drwxr-xr-x. I removed the contents of cpresrouces based on another solution found on google but didn’t help. I’m missing something!

I was syncing my .env file and general.php when this began. In .env I made WEB_ROOT_PATH like this:

WEB_ROOT_PATH=/Users/cbad/websites/nitro/core/cms/web/

In general.php I did this:

'resourceBasePath' => App::env('WEB_ROOT_PATH').'cpresources',

If it helps, here are the permissions on the folders. They seem to be the same as those on a site that doesn’t get this error:

drwxr-xr-x  2 cbad  staff    64 Mar  7 16:55 assets
drwxr-xr-x  2 cbad  staff    64 Mar  7 16:27 cpresources
-rw-rw-rw-@ 1 cbad  staff   604 Feb  5 20:12 index.php
-rw-rw-rw-@ 1 cbad  staff  1202 Feb  5 20:12 web.config

It seems to resolve to the correct location, but I get the error listed above. Is it obvious what I’m doing wrong?

Thanks!

One Answer

This path is on your host machine but this isn't how docker sees things. To Nitro, the location of the folder is /app/web/cpresources.

Without going into too much details, I'd recommend going with an alias instead of hard-setting your webroot the way you are currently doing it. Doing so will make your scaffolding just work without having to change this path every time.

In your config/general.php define your webroot alias like this:

'aliases' => [
    'webroot' => dirname(__DIR__) . '/web'
],

You can then remove 'resourceBasePath' => App::env('WEB_ROOT_PATH').'cpresources', altogether since its default value is already correct.

This alias will also be handy for setting things like File System Path on your volumes.

Correct answer by Oli on June 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP