Skip to content

Seeders are not running on Windows #66

@danielreales7

Description

@danielreales7

What were you trying to do?

I'm launching an application on a Windows 11 Pro tablet with .exe and I can't get the seeders to run.
The application and seeders work fine when running locally from macOS, but not from the .exe file on Windows.

I have the following:

public function boot(): void
    {
        Log::info('NativeAppServiceProvider boot() started');

        Window::open()
            ->maximized();

        $productCount = Product::count();
        Log::info('Product count: '.$productCount);

        if ($productCount === 0) {
            Log::info('No products found, running seeder...');
            try {
                // Define STDIN if it doesn't exist (Windows NativePHP builds)
                if (! defined('STDIN')) {
                    define('STDIN', fopen('php://stdin', 'r'));
                }

                Artisan::call('db:seed', ['--no-interaction' => true]);
                Log::info('Seeder completed. New product count: '.Product::count());
            } catch (\Throwable $e) {
                Log::error('Seeder failed: '.$e->getMessage());
            }
        } else {
            Log::info('Products already exist, skipping seeder');
        }
    }

The application opens perfectly, but if I went to the errors I saw the following: Seeder failed: Undefined constant "STDIN".

I added:

if (! defined('STDIN')) {
    define('STDIN', fopen('php://stdin', 'r'));
}

And now it's not showing Seeders errors, but I'm getting ChildProcess errors.

It's true that I deleted the /dist folder and recompiled, and now I have no errors in the logs folder, but the seeder isn't running and I have plenty of Log::info files to debug, but I can't see any of them.

What happened?

Run seeders correctly.

How to reproduce the bug

<?php

return [
    /**
     * The version of your app.
     * It is used to determine if the app needs to be updated.
     * Increment this value every time you release a new version of your app.
     */
    'version' => env('NATIVEPHP_APP_VERSION', '1.0.0'),

    /**
     * The ID of your application. This should be a unique identifier
     * usually in the form of a reverse domain name.
     * For example: com.nativephp.app
     */
    'app_id' => env('NATIVEPHP_APP_ID', 'com.nativephp.app'),

    /**
     * If your application allows deep linking, you can specify the scheme
     * to use here. This is the scheme that will be used to open your
     * application from within other applications.
     * For example: "nativephp"
     *
     * This would allow you to open your application using a URL like:
     * nativephp://some/path
     */
    'deeplink_scheme' => env('NATIVEPHP_DEEPLINK_SCHEME'),

    /**
     * The author of your application.
     */
    'author' => env('NATIVEPHP_APP_AUTHOR'),

    /**
     * The copyright notice for your application.
     */
    'copyright' => env('NATIVEPHP_APP_COPYRIGHT'),

    /**
     * The description of your application.
     */
    'description' => env('NATIVEPHP_APP_DESCRIPTION', 'An awesome app built with NativePHP'),

    /**
     * The Website of your application.
     */
    'website' => env('NATIVEPHP_APP_WEBSITE', 'https://nativephp.com'),

    /**
     * The default service provider for your application. This provider
     * takes care of bootstrapping your application and configuring
     * any global hotkeys, menus, windows, etc.
     */
    'provider' => \App\Providers\NativeAppServiceProvider::class,

    /**
     * A list of environment keys that should be removed from the
     * .env file when the application is bundled for production.
     * You may use wildcards to match multiple keys.
     */
    'cleanup_env_keys' => [
        'AWS_*',
        'AZURE_*',
        'GITHUB_*',
        'DO_SPACES_*',
        '*_SECRET',
        'BIFROST_*',
        'NATIVEPHP_UPDATER_PATH',
        'NATIVEPHP_APPLE_ID',
        'NATIVEPHP_APPLE_ID_PASS',
        'NATIVEPHP_APPLE_TEAM_ID',
        'NATIVEPHP_AZURE_PUBLISHER_NAME',
        'NATIVEPHP_AZURE_ENDPOINT',
        'NATIVEPHP_AZURE_CERTIFICATE_PROFILE_NAME',
        'NATIVEPHP_AZURE_CODE_SIGNING_ACCOUNT_NAME',
    ],

    /**
     * A list of files and folders that should be removed from the
     * final app before it is bundled for production.
     * You may use glob / wildcard patterns here.
     */
    'cleanup_exclude_files' => [
        'build',
        'temp',
        'content',
        'node_modules',
        '*/tests',
    ],

    /**
     * The NativePHP updater configuration.
     */
    'updater' => [
        /**
         * Whether or not the updater is enabled. Please note that the
         * updater will only work when your application is bundled
         * for production.
         */
        'enabled' => env('NATIVEPHP_UPDATER_ENABLED', true),

        /**
         * The updater provider to use.
         * Supported: "github", "s3", "spaces"
         */
        'default' => env('NATIVEPHP_UPDATER_PROVIDER', 'spaces'),

        'providers' => [
            'github' => [
                'driver' => 'github',
                'repo' => env('GITHUB_REPO'),
                'owner' => env('GITHUB_OWNER'),
                'token' => env('GITHUB_TOKEN'),
                'vPrefixedTagName' => env('GITHUB_V_PREFIXED_TAG_NAME', true),
                'private' => env('GITHUB_PRIVATE', false),
                'channel' => env('GITHUB_CHANNEL', 'latest'),
                'releaseType' => env('GITHUB_RELEASE_TYPE', 'draft'),
            ],

            's3' => [
                'driver' => 's3',
                'key' => env('AWS_ACCESS_KEY_ID'),
                'secret' => env('AWS_SECRET_ACCESS_KEY'),
                'region' => env('AWS_DEFAULT_REGION'),
                'bucket' => env('AWS_BUCKET'),
                'endpoint' => env('AWS_ENDPOINT'),
                'path' => env('NATIVEPHP_UPDATER_PATH', null),
            ],

            'spaces' => [
                'driver' => 'spaces',
                'key' => env('DO_SPACES_KEY_ID'),
                'secret' => env('DO_SPACES_SECRET_ACCESS_KEY'),
                'name' => env('DO_SPACES_NAME'),
                'region' => env('DO_SPACES_REGION'),
                'path' => env('NATIVEPHP_UPDATER_PATH', null),
            ],
        ],
    ],

    /**
     * The queue workers that get auto-started on your application start.
     */
    'queue_workers' => [
        'default' => [
            'queues' => ['default'],
            'memory_limit' => 128,
            'timeout' => 60,
            'sleep' => 3,
        ],
    ],

    /**
     * Define your own scripts to run before and after the build process.
     */
    'prebuild' => [
        'npm run build',
        //        'php artisan optimize'
    ],

    'postbuild' => [
        //        'npm run release'
    ],

    /**
     * Custom PHP binary path.
     */
    'binary_path' => env('NATIVEPHP_PHP_BINARY_PATH', null),
];
public function phpIni(): array
    {
        return [
            'memory_limit' => '512M',
            'display_errors' => '1',
            'error_reporting' => 'E_ALL',
            'max_execution_time' => '0',
            'max_input_time' => '0',
        ];
    }

Debug Output

Array
(
    [Environment] => Array
        (
            [PHP] => Array
                (
                    [Version] => 8.4.13
                    [Path] => /Users/daniel/Library/Application Support/Herd/bin/php84
                )

            [Laravel] => Array
                (
                    [Version] => 12.41.1
                    [ConfigCached] => 
                    [RoutesCached] => 
                    [DebugEnabled] => 1
                )

            [Node] => Array
                (
                    [Version] => v22.21.1
                    [Path] => /Users/daniel/.nvm/versions/node/v22.21.1/bin/node
                )

            [NPM] => Array
                (
                    [Version] => 10.9.4
                    [Path] => /Users/daniel/.nvm/versions/node/v22.21.1/bin/npm
                )

            [OperatingSystem] => Darwin
        )

    [NativePHP] => Array
        (
            [Versions] => Illuminate\Support\Collection Object
                (
                    [items:protected] => Array
                        (
                            [nativephp/desktop] => 2.0.2.0
                            [nativephp/php-bin] => 1.1.1.0
                        )

                    [escapeWhenCastingToString:protected] => 
                )

            [Configuration] => Array
                (
                    [Provider] => App\Providers\NativeAppServiceProvider
                    [BuildHooks] => Array
                        (
                            [Pre] => Array
                                (
                                    [0] => npm run build
                                )

                            [Post] => Array
                                (
                                )

                        )

                    [NotarizationEnabled] => 
                    [AzureTrustedSigningEnabled] => 
                    [CustomPHPBinary] => 
                )

        )

)

Which operating systems have you seen this occur on?

No response

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions