beyondcode / herd-community

88 stars 1 forks source link

[Bug]: Dumps not working on windows #984

Closed simonjcarr closed 4 weeks ago

simonjcarr commented 1 month ago

Platform

Windows

Operating system version

Windows 11

System architecture

Intel (x86)

Herd Version

1.10.0

PHP Version

8.3.11

Bug description

I am not getting dumps in herd. I am using

Here is my composer.json

"name": "laravel/laravel",
    "type": "project",
    "description": "The skeleton application for the Laravel framework.",
    "keywords": ["laravel", "framework"],
    "license": "MIT",
    "require": {
        "php": "^8.2",
        "inertiajs/inertia-laravel": "^1.0",
        "laravel/framework": "^11.9",
        "laravel/jetstream": "^5.1",
        "laravel/sanctum": "^4.0",
        "laravel/tinker": "^2.9",
        "mlocati/ip-lib": "^1.18",
        "tightenco/ziggy": "^2.0"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.13",
        "barryvdh/laravel-ide-helper": "^3.1",
        "fakerphp/faker": "^1.23",
        "laravel/pint": "^1.13",
        "laravel/sail": "^1.26",
        "mockery/mockery": "^1.6",
        "nunomaduro/collision": "^8.0",
        "phpunit/phpunit": "^11.0.1"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi",
            "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
            "@php artisan migrate --graceful --ansi"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "php-http/discovery": true
        }
    },
    "minimum-stability": "stable",
    "prefer-stable": true
}

Steps to reproduce

I purchased Herd Pro I click show dumps image I toggle Intercepting off and on I add both dump and dd into my code. I refresh the browser Nothing is displayed in dumps image Dumps status is green

Here is the controller method being run that contains a dump, but does not appear in herd.

 public function index() {
        dump("This is a test");
        return Inertia::render('Designs/Index', [
            'designs' => Auth::user()->designs()->with('team')->get()
        ]);
    }

Relevant log output

No response

sschlein commented 1 month ago

My guess is that there is somehow an old php process running and serving your requests. Could you please restart all Herd services via the dashboard or the system tray menu?

docmedicus-support commented 1 month ago

We have the same problem in Windows. Dumps have never worked for us (having restarted services, re-enabled in Dump Windows, etc.)

Is there any advice on what to check / how to debug?

mpociot commented 1 month ago

@docmedicus-support We add a custom php.ini directive called auto_prepend_file. Does that exist for you? Also make sure that the dump server and internal API port are marked as "green"/available.

docmedicus-support commented 1 month ago

@mpociot We do have the following line in our php.ini:

auto_prepend_file=C:\\Program Files\\Herd\\resources\\app.asar.unpacked\\resources\\valet\\dump-loader.php

Dumps is green in Active Services, we also have a green dot in the Dumps tab.

We do have 2 PHP entries in Active Services (one seems to be debug), is that normal?

docmedicus-support commented 1 month ago

Just updated to 1.11.0, still not working

mpociot commented 1 month ago

@docmedicus-support the two active services is normal, yeah.

Do you see dump calls made via the CLI? For example:

php artisan tinker
dump("test");

This should also show up in the Herd UI

docmedicus-support commented 1 month ago

No, no output in Dump Viewer:

Psy Shell v0.12.4 (PHP 8.3.7 — cli) by Justin Hileman
> dump('Test')
"Test" // vendor\psy\psysh\src\ExecutionLoopClosure.php(52) : eval()'d code:1
= "Test"
mpociot commented 1 month ago

But this is using the correct PHP binary, right?

Just to double check:

ini_get('auto_prepend_file');

should point to the dump-loader.php file.

And what do you get when you run this in tinker:

\BeyondCode\HerdConfiguration\HerdConfiguration::load()->dumpsEnabled();
docmedicus-support commented 1 month ago

But this is using the correct PHP binary, right?

Well, I am not really sure how to check that tbh...should be though...

Just to double check:

ini_get('auto_prepend_file');
> ini_get('auto_prepend_file');
= "C:\\Program Files\\Herd\\resources\\app.asar.unpacked\\resources\\valet\\dump-loader.php"

And what do you get when you run this in tinker:

\BeyondCode\HerdConfiguration\HerdConfiguration::load()->dumpsEnabled();

This might actually be what makes this a bit tricky. This is a domain joind system, our profile is mapped to a server location via GPO. The output is:

 Exception  Herd configuration file not found at H:\\.config\herd\config\config.json.

H: being the mapped SMB share where my profile resides. The actual Herd config files are in:

C:\Users\{myuser}\.config\herd\config
mpociot commented 1 month ago

Yeah this is what's causing issues here.

So we are building the path to check for your config.json like this:

if (array_key_exists('HOME', $_SERVER)) {
    $path = $_SERVER['HOME'] . '\.config\herd\config';
} else if (array_key_exists('HOMEPATH', $_SERVER) && array_key_exists('HOMEDRIVE', $_SERVER)) {
    $path = $_SERVER['HOMEDRIVE'] . $_SERVER['HOMEPATH'] . '\.config\herd\config';
}

I don't think there's an easy way we can detect something like makked SMB shared with profiles though. Can you create a symlink so that herd can find the config file?

docmedicus-support commented 1 month ago

I tried but it wouldn't be possible without major hurdles. The home share is only available for the current user but I can only create the symlink with admin rights. The admin account cannot access the share though (and mklink cannot create links to targets that are not currently available).

Would it be possible to add a way to override the config location?

sschlein commented 1 month ago

Hi @docmedicus-support – we discussed this internally and there is currently no way to make this work with your setup. We don't see a way to make that work in the mid-term (6 months) roadmap 🙈

In case that this is a dealbreaker for you and your license is less than 3 months old, can you please email us at support@beyondco.de so we can process a refund?

docmedicus-support commented 1 month ago

Hi @sschlein I would need to check but I think our license is older. We would really to prefer to keep using Herd though...to bad this seems to break functionality for us. I am a little puzzled as to why other parts of Herd seem to work normally. All the binaries, databases etc. don't seem to have any problems. What I can try is to mirror my config to the SMB share once a day or so. Would the config.json be enough? Should I mirror the whole structure (could be problematic due to the files in use). Really not ideal but I hope we can find some kind of workaround...

docmedicus-support commented 1 month ago

To follow up on this:

I copied all JSON files and the license to .config\herd\config on my share an Dumps started working immediately.

So while this is not really a solution at least we can use the Dumps now. Do you suspect any other part of the package to not work correctly in our setting?

sschlein commented 1 month ago

To be honest, I wonder why it works at all 🙈

It's hard to tell if there are other features that could also break, can you try the Mail feature? The database of the Mail server should also live in the config directory.

It's awesome that it works when copying the files, the config files don't change that often on a day to day usage, the only thing that we write with every request is the last visited site – but even without that all related features should work you may only need to select a site or Mail inbox manually because Herd can't read the last (real) request localtion.

docmedicus-support commented 1 month ago

I will check and report back whether we have other problems. As I said, most features (seem to) work fine. The mysql database is in config as well, right. No problems there...

You seem to use different mechanisms to determine the location of the config directory in different parts of the package...which might not be ideal? 😏