craftcms / nitro

Speedy local dev environment for @craftcms.
https://getnitro.sh
MIT License
178 stars 24 forks source link

`cpresources` directory in the wrong place #294

Closed lindseydiloreto closed 3 years ago

lindseydiloreto commented 3 years ago

Description

It seems like Nitro is determined to put a cpresources directory at the path, instead of at the webroot. Not sure if there's a bug in Nitro, or if I'm just doing something wrong.

- hostname: project.test
  path: ~/Sites/projects
  version: "7.4"
  webroot: path/to/site/public
  xdebug: false
  blackfire: false

Whenever I load a page of the CP, it incorrectly creates and/or updates this directory...

~/Sites/projects/public/cpresources

... instead of the expected directory...

~/Sites/projects/path/to/site/public/cpresources

It's possible that there's a mistake on my end, if so just let me know!

Steps to reproduce

  1. Create a project where the path and webroot are separate directories.
  2. Load any page of the CP in a browser.
  3. See that the cpresources directory was created in the path instead of the webroot.

Additional info

jasonmccallister commented 3 years ago

@lindseydiloreto do you have an environment variable where you are setting the path?

lindseydiloreto commented 3 years ago
SITE_BASEURL="http://project.test"
SITE_BASEPATH="/app/public"

On my other projects (where I don't seem to be having this issue), the variables are called CONFIG_SITEURL and CONFIG_SITEPATH respectively. I believe those are the Craft default names... does Nitro reference CONFIG_SITEPATH explicitly?

jasonmccallister commented 3 years ago

Nitro sets only PHP specific settings and uses the .env to load what you set. Are there any aliases for the web/root?

lindseydiloreto commented 3 years ago

Not sure if this is what you're asking, but these are my Craft aliases in config/general.php...

'aliases' => [
    '@web'          => null,
    '@webroot'      => getenv('SITE_BASEPATH'),
    '@baseUrl'      => getenv('SITE_BASEURL'),
    '@basePath'     => getenv('SITE_BASEPATH'),
    '@assetsUrl'    => getenv('SITE_BASEURL').'/assets',
    '@assetsPath'   => getenv('SITE_BASEPATH').'/assets',
    '@resourcesUrl' => getenv('SITE_BASEURL').'/resources',
],
lindseydiloreto commented 3 years ago

I got this all sorted out! It was a fundamental misunderstanding of what the /app directory was mapped to.

- hostname: project.test
  path: ~/Sites/projects
  version: "7.4"
  webroot: path/to/site/public
  xdebug: false
  blackfire: false

In this context, the /app directory would be mapped to ~/Sites/projects. Once I realized that, I was able to correct my webroot accordingly.

Thanks for all of your help getting this cleared up @jasonmccallister! 🍺