vercel-community / php

🐘 PHP Runtime for ▲ Vercel Serverless Functions (support 7.4-8.3)

Home Page:https://php.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logs/laravel.log could not be opened.

kresnasatya opened this issue · comments

The stream or file "/var/task/user/storage/logs/laravel.log" could not be opened: failed to open stream: Read-only file system

Hi @f3l1x, I got error message when deploy laravel project that depends on log file. Here's the screenshot.

Screen Shot 2021-01-17 at 12 08 54

Here's the site: https://phpbali-site-o7r82chhh.vercel.app

This log file is a part of settings in https://github.com/GrKamil/laravel-telegram-logging package. When I set LOG_CHANNEL to stack in vercel.json file it throws error like image above.

Here's my vercel.json config:

{
    "version": 2,
    "builds": [
        { "src": "/api/index.php", "use": "vercel-php@0.3.1" },
        { "src": "/public/**", "use": "@vercel/static" }
    ],
    "routes": [
        {
            "src": "/(css|js)/(.*)",
            "dest": "public/$1/$2"
        },
        {
            "src": "/(.*)",
            "dest": "/api/index.php"
        }
    ],
    "env": {
        "APP_ENV": "production",
        "APP_DEBUG": "true",
        "APP_URL": "https://yoursite.com",

        "APP_CONFIG_CACHE": "/tmp/config.php",
        "APP_EVENTS_CACHE": "/tmp/events.php",
        "APP_PACKAGES_CACHE": "/tmp/packages.php",
        "APP_ROUTES_CACHE": "/tmp/routes.php",
        "APP_SERVICES_CACHE": "/tmp/services.php",
        "VIEW_COMPILED_PATH": "/tmp/views",
        "SSR_TEMP_PATH": "/tmp/ssr",

        "CACHE_DRIVER": "array",
        "LOG_CHANNEL": "stack",
        "SESSION_DRIVER": "cookie",
        "NODE_PATH": "node"
    }
}

I thought that I'm missing additional configuration on "env" in vercel.json file.

Hi, I will close the issue. The current solution that I have is create new Laravel project and copy certain files like Controllers, Models and Views to the new Laravel project.

Hi @satyakresna. There is only 1 writable folder, /tmp. You should change log directory, to the /tmp folder.

Hi @f3l1x, thanks for your info.

Hi, I have this exact same problem but I have tried to update the log path to /tmp but that doesn't seem to work? can you point me to the exact location of this change?

Hi @sebszocinski, I am not familiar with laravel in that way. There is only one writable folder /tmp, point everything to this folder.

@f3l1x Yes I understand that, but by default Laravel uses the /storage/logs path and Vercel needs this to be re-routed to /tmp but i'm not sure where you do this in Laravel?

Has anyone found a solution regarding this issue?

i also faced the same issue when tryin to deploy my app to vercel, just fix it by added this to the vercel.json env section
"env": {
"APP_ENV": "production",
"APP_DEBUG": "true",
"APP_URL": "https://makeupbykikiraa.vercel.app",
"CACHE_DRIVER": "array",
"SESSION_DRIVER": "cookie",
"FILESYSTEM_DRIVER": "public",
"APP_CONFIG_CACHE": "/tmp/config.php",
"APP_EVENTS_CACHE": "/tmp/events.php",
"APP_PACKAGES_CACHE": "/tmp/packages.php",
"APP_ROUTES_CACHE": "/tmp/routes.php",
"APP_SERVICES_CACHE": "/tmp/services.php",
"VIEW_COMPILED_PATH": "/tmp",
"LOG_CHANNEL": "stderr"
},