solidtime icon indicating copy to clipboard operation
solidtime copied to clipboard

Cache Path Error

Open tquizzle opened this issue 1 year ago • 14 comments
trafficstars

When trying to just start the scheduler for generate-keys, I am receiving the following:

In Compiler.php line 67:

  Please provide a valid cache path.

tquizzle avatar Sep 05 '24 02:09 tquizzle

Could you provide us with additional information about your setup?

Also did you do the following things before running artisan self-host:generate-keys:

  • Create the environment file (Docs: https://docs.solidtime.io/self-hosting/guides/docker#2-the-environment-files)
  • Correct the permissions for the app-storage and logs folder (Docs: https://github.com/solidtime-io/self-hosting-examples/tree/main/0-docker-traefik-with-database#installation)

korridor avatar Sep 05 '24 10:09 korridor

I have followed along with the docs for solidtime+database and I am getting the same error

2024-09-11 00:46:52] production.ERROR: Please provide a valid cache path. {"exception":"[object] (InvalidArgumentException(code: 0): Please provide a valid cache path. at /var/www/html/vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php:67) [stacktrace] #0 /var/www/html/vendor/laravel/framework/src/Illuminate/View/ViewServiceProvider.php(97): Illuminate\\View\\Compilers\\Compiler->__construct() #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(900): Illuminate\\View\\ViewServiceProvider->Illuminate\\View\\{closure}() #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(787): Illuminate\\Container\\Container->build() #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1041): Illuminate\\Container\\Container->resolve() #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(723): Illuminate\\Foundation\\Application->resolve() #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1026): Illuminate\\Container\\Container->make() #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(1446): Illuminate\\Foundation\\Application->make() #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(237): Illuminate\\Container\\Container->offsetGet() #8 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(208): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance() #9 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(351): Illuminate\\Support\\Facades\\Facade::getFacadeRoot() #10 /var/www/html/vendor/blade-ui-kit/blade-icons/src/BladeIconsServiceProvider.php(98): Illuminate\\Support\\Facades\\Facade::__callStatic() #11 /var/www/html/vendor/blade-ui-kit/blade-icons/src/BladeIconsServiceProvider.php(27): BladeUI\\Icons\\BladeIconsServiceProvider->bootDirectives() #12 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): BladeUI\\Icons\\BladeIconsServiceProvider->boot() #13 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #14 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #15 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod() #16 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call() #17 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1114): Illuminate\\Container\\Container->call() #18 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1095): Illuminate\\Foundation\\Application->bootProvider() #19 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}() #20 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1094): array_walk() #21 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot() #22 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(316): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap() #23 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(470): Illuminate\\Foundation\\Application->bootstrapWith() #24 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(194): Illuminate\\Foundation\\Console\\Kernel->bootstrap() #25 /var/www/html/artisan(35): Illuminate\\Foundation\\Console\\Kernel->handle() #26 {main} "}

memphisraynz avatar Sep 11 '24 00:09 memphisraynz

Could you provide us with additional information about your setup?

Also did you do the following things before running artisan self-host:generate-keys:

  • Create the environment file (Docs: https://docs.solidtime.io/self-hosting/guides/docker#2-the-environment-files)

  • Correct the permissions for the app-storage and logs folder (Docs: https://github.com/solidtime-io/self-hosting-examples/tree/main/0-docker-traefik-with-database#installation)

@memphisraynz Thanks for the stack trace. Did you do the things I asked @tquizzle in the comment before yours?

korridor avatar Sep 12 '24 15:09 korridor

I sure can provide some more information. What other details would help you?

Yes, I performed the generate keys and the guide on the 2 separate .env files

On Fri, 13 Sept 2024, 1:44 am Constantin Graf, @.***> wrote:

Could you provide us with additional information about your setup?

Also did you do the following things before running artisan self-host:generate-keys:

Create the environment file (Docs: https://docs.solidtime.io/self-hosting/guides/docker#2-the-environment-files )

Correct the permissions for the app-storage and logs folder (Docs: https://github.com/solidtime-io/self-hosting-examples/tree/main/0-docker-traefik-with-database#installation )

@memphisraynz https://github.com/memphisraynz Thanks for the stack trace. Did you do the things I asked @tquizzle https://github.com/tquizzle in the comment before yours?

— Reply to this email directly, view it on GitHub https://github.com/solidtime-io/solidtime/issues/169#issuecomment-2346646516, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACK3OCERJTUDC5PCDSMCPBTZWGZGPAVCNFSM6AAAAABNVPNVYCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBWGY2DMNJRGY . You are receiving this because you were mentioned.Message ID: @.***>

memphisraynz avatar Sep 12 '24 22:09 memphisraynz

@memphisraynz Just to be safe, you also ran chown -R 1000:1000 app-storage logs before running artisan self-host:generate-keys?

If yes, please pull the latest version of the example repository. I fixed a few things, and it is possible that one of those changes also resolve your problem. (Commit)

If this does not resolve your issue, please write here again, and I'll inform you about the information I need to further debug the issue.

korridor avatar Sep 13 '24 15:09 korridor

I have the same issue. I'm trying to set up solidtime on a Raspberry Pi 4 with Portainer. I'm running nginx as reverse proxy in a different stack. Though I doubt that's relevant for this issue.

What I did:

  • First I ran docker run --rm solidtime/solidtime:main php artisan self-host:generate-keys to get the needed keys.
  • Then I adjusted the docker-compose and env files to my needs
    • note: I'm using the main image for arm64 support.
  • Then I created the needed folders (see compose file) on the rpi and gave the user (1000:1000) ownership of the folders.
  • Finally I used the compose and env files to set up and start a stack via portainer.

The database reports healthy. All other containers show the error and call stack reported above.

docker compose
services:
  solidtime:
    image: solidtime/solidtime:main
    container_name: solidtime
    restart: always
    user: 1000:1000
    expose:
      - 8000
    volumes:
      - /opt/solidtime/storage:/var/www/html/storage
      - /opt/solidtime/storage/logs:/var/www/html/storage/logs
      - /opt/solidtime/storage/app:/var/www/html/storage/app
    environment:
      CONTAINER_MODE: http
      AUTO_DB_MIGRATE: true
    healthcheck:
      test: [ "CMD-SHELL", "curl --fail http://localhost:8000/health-check/up || exit 1" ]
    env_file:
      - stack.env
    depends_on:
      - solidtime-database
  solidtime-scheduler:
    image: solidtime/solidtime:main
    container_name: solidtime-scheduler
    restart: always
    user: 1000:1000
    volumes:
      - /opt/solidtime/storage:/var/www/html/storage
      - /opt/solidtime/storage/logs:/var/www/html/storage/logs
      - /opt/solidtime/storage/app:/var/www/html/storage/app
    environment:
      CONTAINER_MODE: scheduler
    healthcheck:
      test: [ "CMD-SHELL", "supervisorctl status scheduler:scheduler_00" ]
    env_file:
      - stack.env
    depends_on:
      - solidtime-database
  solidtime-queue:
    image: "solidtime/solidtime:main"
    container_name: solidtime-queue
    restart: always
    user: 1000:1000
    volumes:
      - /opt/solidtime/storage:/var/www/html/storage
      - /opt/solidtime/storage/logs:/var/www/html/storage/logs
      - /opt/solidtime/storage/app:/var/www/html/storage/app
    environment:
      CONTAINER_MODE: worker
      WORKER_COMMAND: "php /var/www/html/artisan queue:work"
    healthcheck:
      test: [ "CMD-SHELL", "supervisorctl status worker:worker_00" ]
    env_file:
      - stack.env
    depends_on:
      - solidtime-database
  solidtime-database:
    image: postgres:15
    container_name: solidtime-database
    restart: always
    environment:
      PGPASSWORD: '${DB_PASSWORD:-secret}'
      POSTGRES_DB: '${DB_DATABASE}'
      POSTGRES_USER: '${DB_USERNAME}'
      POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
    volumes:
      - /opt/solidtime/postgres:/var/lib/postgresql/data
    healthcheck:
      test:
        - CMD
        - pg_isready
        - '-q'
        - '-d'
        - '${DB_DATABASE}'
        - '-U'
        - '${DB_USERNAME}'
      retries: 3
      timeout: 5s
env
APP_DOMAIN=rpi.local
DB_DATABASE=solidtime
DB_USERNAME=solidtime
FORWARD_APP_PORT=8000
FORWARD_DB_PORT=5432
DB_PASSWORD=MYDBPASS
SOLIDTIME_IMAGE_TAG=latest

CONTAINER_MODE=http
APP_NAME=solidtime
VITE_APP_NAME=solidtime
APP_ENV=production
APP_DEBUG=false
APP_URL="https://solidtime.rpi.local"
APP_FORCE_HTTPS=true
TRUSTED_PROXIES="0.0.0.0/0,2000:0:0:0:0:0:0:0/3"
APP_KEY="MYAPPKEY"
PASSPORT_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----MYPRIVATEKEY-----END PRIVATE KEY-----"
PASSPORT_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----MYPUBLICKEY-----END PUBLIC KEY-----"
SUPER_ADMINS=""
LOG_CHANNEL=stderr_daily
LOG_LEVEL=debug
DB_CONNECTION=pgsql
DB_HOST=solidtime-database
DB_PORT=5432
DB_SSLMODE=require
MAIL_MAILER=smtp
MAIL_HOST=""
MAIL_PORT=""
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME=solidtime
MAIL_USERNAME=""
MAIL_PASSWORD=""
QUEUE_CONNECTION=database
FILESYSTEM_DISK=local
PUBLIC_FILESYSTEM_DISK=public

IHappyDayI avatar Sep 14 '24 18:09 IHappyDayI

Well, seems like I figured it out (with the help of ChatGPT). It's not enough to create the app-storage and logs folders with the correct permissions, but apparently you also need app-storage/framework/cache. This fixes the issue for me.

IHappyDayI avatar Sep 14 '24 21:09 IHappyDayI

It's not enough to create the app-storage and logs folders with the correct permissions, but apparently you also need app-storage/framework/cache. This fixes the issue for me.

@IHappyDayI mind sharing exactly which paths you're mounting from the container?

Unless you're literally just mapping "/app-storage/framework/cache" from the container to the host, it seems to be one of those "it works on my machine" situations.

whallin avatar Sep 15 '24 14:09 whallin

I'm mounting exactly what's defined in my docker compose file I posted above.

volumes:
  - /opt/solidtime/storage:/var/www/html/storage
  - /opt/solidtime/storage/logs:/var/www/html/storage/logs
  - /opt/solidtime/storage/app:/var/www/html/storage/app

Though, I guess the very first mount point would be enough (in my setup) because the other paths are contained in the first path.

As far as I understand, the issue is that the docker user can't create new folders in the mounted path on my host machine (/opt/solidtime/storage). That's why the readme of the self hosting example mentions to correct the permissions of the mounted paths.

However, it seems that solidtime / Laravel wants to cache files in /var/www/html/storage/framework/cache, which corresponds to /opt/solidtime/storage/framework/cache on my host system. The container doesn't have permission to create those folders. So just make sure that you create the framework and cache folders with proper permissions on the host machine before starting the container. The cache folder is already mounted as a subfolder of /var/www/html/storage.

IHappyDayI avatar Sep 16 '24 00:09 IHappyDayI

@IHappyDayI I suspect that the folders don't have the correct file permissions and that is why even though the folders have the correct owner, Laravel cannot create subfolders (which it needs to be able to do, not only for the framework/cache folder).

Could you send me the output of the following commands:

ls -al /opt/solidtime/storage
ls -al /opt/solidtime/storage/app/framework

Furthermore, there is currently a separate issue with the ARM image. If you can run the queue and the scheduler without problems, but the app container is stuck in a restart loop, then you are having the same issue as I on ARM. I'm currently investigating. Please keep in mind that the ARM image is not officially released yet, which is why it is only in the main tag and not in the latest tag.

korridor avatar Sep 16 '24 09:09 korridor

Could you send me the output of the following commands:

raspberrypi ~ # ls -al /opt/solidtime/storage
total 20
drwxr-xr-x 5 mhermann root 4096 Sep 14 22:46 .
drwxr-xr-x 4 root     root 4096 Sep 14 22:45 ..
drwxr-xr-x 2 mhermann root 4096 Sep 14 22:46 app
drwxr-xr-x 4 mhermann root 4096 Sep 14 22:46 framework
drwxr-xr-x 2 mhermann root 4096 Sep 16 02:11 logs
total 16
drwxr-xr-x 4 mhermann root 4096 Sep 14 22:46 .
drwxr-xr-x 5 mhermann root 4096 Sep 14 22:46 ..
drwxr-xr-x 3 mhermann root 4096 Sep 14 23:03 cache
drwxr-xr-x 2 mhermann root 4096 Sep 14 22:46 views

Like mentioned above, manually creating the storage/framework/cache folder and setting the correct owner fixes the issue for me. I highly suspect, that Laravel just expects the folder to exist and doesn't even try to create it. I have had similar experiences with other docker containers. Once the necessary folders are there, the solidtime containers start up and the cache folder gets filled with data, including new subfolders.

I think the solution is to extend the readme/docs to include the following note, or something along those lines:

  • On the host machine, create the folder structure storage/framework/cache
  • Make sure all mounted and newly created folders have the correct owner (UID=1000) chown -R 1000:1000 app-storage logs framework

This is a thread from Stack Overflow that suggest the same underlying issue. Laravel expects the folders to exist and doesn't create them automatically.

Furthermore, there is currently a separate issue with the ARM image. If you can run the queue and the scheduler without problems, but the app container is stuck in a restart loop, then you are having the same issue as I on ARM. I'm currently investigating. Please keep in mind that the ARM image is not officially released yet, which is why it is only in the main tag and not in the latest tag.

Yeah, I noticed that issue. Glad to hear you're looking into it. I'm exited to host solidtime on my rpi.

IHappyDayI avatar Sep 16 '24 11:09 IHappyDayI

I can see this got marked with a 'needs reproduction' tag. What can I do to help diagnose this?

memphisraynz avatar Oct 02 '24 23:10 memphisraynz

@IHappyDayI Sorry for the delayed response. Thank you for sending the ls outputs. The permissions of your folders are not correct (1000 != root). If you follow our guide, the folder permissions should be correct. If you do your own setup, please ensure that the PHP process can write in the folders relevant to running a Laravel application.

korridor avatar Oct 03 '24 11:10 korridor

@memphisraynz Did you already do the things that I wrote you in this comment? https://github.com/solidtime-io/solidtime/issues/169#issuecomment-2349189628

korridor avatar Oct 03 '24 11:10 korridor

Just wanted to help anyone further, i was missing chmod -R 775 app-storage

kdurek avatar Jan 31 '25 13:01 kdurek

If you are using this volume mount

volumes:
  - /opt/solidtime/storage:/var/www/html/storage

then you need to create framework/views and framework/cache directories. Also, chmod -R 775 storage along with chown -R 1000:1000 storage

directory structure as follows

storage
├── app
├── framework
│   ├── cache
│   └── views
└── logs

smit-io avatar Feb 03 '25 11:02 smit-io

This error is replicable when pulling up the container. The docs do not say to create anything like /opt/solidtime/storage, they only mention app-storage and logs: https://github.com/solidtime-io/self-hosting-examples/tree/main/1-docker-with-database#installation

when pulling up the docker, the logs will say:

sudo docker compose logs -f
scheduler-1  | Container mode: scheduler
scheduler-1  | [2025-09-30 14:03:16] production.ERROR: Please provide a valid cache path. {"exception":"[object] (InvalidArgumentException(code: 0): Please provide a valid cache path. at /var/www/html/vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php:75)
scheduler-1  | [stacktrace]
scheduler-1  | #0 /var/www/html/vendor/laravel/framework/src/Illuminate/View/ViewServiceProvider.php(97): Illuminate\\View\\Compilers\\Compiler->__construct()
scheduler-1  | #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(1010): Illuminate\\View\\ViewServiceProvider->Illuminate\\View\\{closure}()
scheduler-1  | #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(890): Illuminate\\Container\\Container->build()
scheduler-1  | #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1077): Illuminate\\Container\\Container->resolve()
scheduler-1  | #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(821): Illuminate\\Foundation\\Application->resolve()
scheduler-1  | #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1057): Illuminate\\Container\\Container->make()

This error will then repeat through all other containers, forever. The reason, I think, is:

volumes:
      - "app-storage:/var/www/html/storage"
      - "./logs:/var/www/html/storage/logs"
      - "./app-storage:/var/www/html/storage/app"

So you end up with a Frankenstein: some parts come from a hidden Docker volume, others from your host. That’s why Laravel complains: things like storage/framework/views are missing because the base storage dir is swallowed by the first line.

The proper approach is to either use docker volume or host volume

In my case I chose host volume because it is more manageable and cleaner, but you have to manually add the folders, since the code does not check for it:

mkdir -p app-storage/app
mkdir -p app-storage/framework/{cache,sessions,views}
mkdir -p logs

(chown properly) then

volumes:
  - ./app-storage:/var/www/html/storage
  - ./logs:/var/www/html/storage/logs

This needs to be corrected in the docker file, and ideally, it should create the subfolders on its own.

smileBeda avatar Sep 30 '25 14:09 smileBeda