Skip to content

Executing "Force Java compilation" from the command palette shows confusing error message #437

Description

@gorkem

I get a Command 'Java: Force Java compilation' can not be run from here. error dialog when I execute force Java Compilation on a multi-root project. Although it looks like the compilation seems to execute.

Activity

  1. fbricon commented on Feb 13, 2018

    @fbricon
    Collaborator

    I guess we need to change the scope of the command to something workspace friendly

  2. fbricon commented on Feb 15, 2018

    @fbricon
    Collaborator

    Alt+Shift+B works for me, how did you run the command?

  3. gorkem commented on Feb 15, 2018

    @gorkem
    ContributorAuthor

    command palette of course

  4. fbricon commented on Feb 15, 2018

    @fbricon
    Collaborator

    Ok so this is not a multi-root problem. The problem is caused by the server build failing , eg. due to compilation errors, then the promise is rejected L197:

    commands.registerCommand(Commands.COMPILE_WORKSPACE, (isFullCompile : boolean) => {
    return window.withProgress({ location: ProgressLocation.Window }, async p => {
    if (typeof isFullCompile !== 'boolean') {
    const selection = await window.showQuickPick(['Incremental', 'Full'], {'placeHolder' : 'please choose compile type:'});
    isFullCompile = selection !== 'Incremental';
    }
    p.report({ message: 'Compiling workspace...' });
    const start = new Date().getTime();
    const res = await languageClient.sendRequest(CompileWorkspaceRequest.type, isFullCompile);
    const elapsed = new Date().getTime() - start;
    const humanVisibleDelay = elapsed < 1000? 1000:0;
    return new Promise((resolve, reject) => {
    setTimeout(() => { // set a timeout so user would still see the message when build time is short
    if (res === CompileWorkspaceStatus.SUCCEED) {
    resolve(res);
    } else {
    reject(res);
    }
    }, humanVisibleDelay);
    });
    });
    });

    When the command results fails, when launched from the command palette, vscode reports it couldn't run the command. When launched from a shortcut, rejected promise is ignored. Not sure what the best way is to deal with that. @ansyral any idea?

  5. changed the title [-]Force compilation error on multi-root workspaces[/-] [+]Executing "Force Java compilation" from the command palette shows confusing error message[/+] on Feb 15, 2018
  6. mojo2012 commented on Jun 5, 2018

    @mojo2012

    It should be made more obvious, that there was a build error. Because I never thought of that. I though my installation is messed up

  7. MeherSru commented on Sep 29, 2026

    @MeherSru
    Contributor

    This looks fixed by (#4032). I ran Java: Force Java Compilation → Full on a project with a compile error, in both single-folder and multi-root workspaces, and the "can not be run from here" error no longer appears.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions