Command handler results in Could not start contribution TypeError: Cannot read properties of undefined (reading 'resolved')

Hi all,
I implemented method and to test it I created command to call this method. My command works perfectly when it contains only this.messageService.info(‘some string’) but when I try to call my method, it results in this:

my code looks like this:
example class (simplified just to make sure the error is not inside)

import { injectable } from '@theia/core/shared/inversify';

@injectable()
export class CMakeListGenerator {
  public generate(content: string): string {
    let result: string;
    result = 'AHOJ ';
    result = result.concat(jsonFile);
    console.log('RESULT: ' + content);
    return result;
  }
}

And command definition:

export const CMAKE_COMMAND: Command = {
  id: 'CMAKE_COMMAND.command',
  label: 'Generate CMAKE',
};

@injectable()
export class CMakeCommandContribution implements CommandContribution {
  constructor(@inject(CMakeListGenerator) private readonly cmakeListGenerator: CMakeListGenerator) {}

  registerCommands(commands: CommandRegistry): void {
    commands.registerCommand(CMAKE_COMMAND, { execute: () => this.cmakeListGenerator.generate(PROJECT_HTC) });
  }
}

I know I can test the method differently, I just wanted to use the command as it will be needed at the end in some way, so is there something I am generally missing?
Thank you

@CrixOv thank you for the discussion, do you mind sharing details of how you update the -module.ts to bind your classes and contributions? If possible you can also share your extension in a public GitHub repository (or a reproducible example).

Hello, binding is very simple:

import { CommandContribution } from ‘@theia/core/lib/common’;
import { ContainerModule } from ‘@theia/core/shared/inversify’;
import { CMakeCommandContribution } from ‘./cmake-command-contribution’;

export default new ContainerModule((bind) => {
bind(CommandContribution).to(CMakeCommandContribution);
});

@CrixOv I believe bindings are missing:

export default new ContainerModule((bind) => {
+ bind(CMakeListGenerator).toSelf().inSingletonScope();
+ bind(CMakeCommandContribution).toSelf().inSingletonScope();
+ bind(CommandContribution).toService(CMakeCommandContribution);
- bind(CommandContribution).to(CMakeCommandContribution);
});

Yes :grinning: :roll_eyes: as usual for me. Thank you and sorry for that stupid question…bindings are the weak point for me …