Skip to content

php artisan register:app fails: "There are no commands defined in the "register" namespace" #1606

Description

@HK-Moebius

Registering a private app as described in the Heimdall-Apps wiki no longer works. The command exists in app/Console/Commands/RegisterApp.php, but artisan does not know it.

Steps to reproduce

  1. Put a private app folder, e.g. MyApp, into SupportedApps.
  2. Run:
    docker exec -it heimdall php /app/www/artisan register:app MyApp
    

Expected behaviour

Application Added - MyApp - <appid>

Actual behaviour

ERROR  There are no commands defined in the "register" namespace.

php artisan list does not show register:app either.

Cause

Since the move to the new Laravel application structure, bootstrap/app.php only passes the console routes file to withRouting():

->withRouting(
    ...
    commands: __DIR__.'/../routes/console.php',
    ...
)

withRouting() then calls withCommands([routes/console.php]). Because that array is not empty, ApplicationBuilder::withCommands() does not add its default path app/Console/Commands. As a result, RegisterApp is never discovered.

Suggested fix

Register the commands directory explicitly in bootstrap/app.php, for example:

->withCommands([
    __DIR__.'/../app/Console/Commands',
])

Workaround

Until this is fixed, the command can be registered and run manually:

docker exec -i heimdall sh -c 'cat > /tmp/register.php' <<'PHP'
<?php
require '/app/www/vendor/autoload.php';
$app = require '/app/www/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
$kernel->registerCommand($app->make(App\Console\Commands\RegisterApp::class));
$kernel->call('register:app', ['folder' => 'MyApp']);
echo $kernel->output();
PHP
docker exec -it -u abc heimdall php /tmp/register.php

Environment

  • Heimdall version: 2.8.3
  • Installation: linuxserver/heimdall Docker image on Unraid

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions