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

Open Beginner friendly
#1,606 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
laravel, php
Domain
cli

Research direction

Start with bootstrap/app.php and app/Console/Commands/RegisterApp.php, then reproduce the failure with the documented docker exec artisan register:app MyApp command. Verify that artisan list exposes register:app and that running it produces the expected Application Added output for a private app.

Written by the indexing model from the issue text.

Description

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
Dominant language
PHP
Stars
9.3k
Forks
629
Avg merge
1d 12h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from linuxserver/Heimdall

All issues in linuxserver/Heimdall

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.