Theia: @theia/task Doesn't run task, creates new terminal

Created on 31 Jul 2019  路  12Comments  路  Source: eclipse-theia/theia

Description

Terminal/Run task does not execute the example tasks in the tasks readme. Instead, it opens new terminals. To verify it wasn't my environment, I spun up a vm in gcloud with a bash environment. Here are some gifs to demonstrate:

  • On my zsh environment:

theiaTaskIssue

  • On the gcloud bash environment:

theiaTaskIssue2

Reproduction Steps

This is while developing my own extension, so to be sure I started a new "hello world" extension project using the tutorial steps. Then I go into "browser-app", execute:

yarn add @theia/task

to add the extension. I also tried running yarn add in my extension directory.

Restart the project and try to run a task.

OS and Theia version:

  • zsh environment:

Linux pop-os 5.0.0-21-generic #22+system76-Ubuntu SMP Tue Jul 16 19:57:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

-gcloud bash environment:

Linux 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u3 (2019-06-16) x86_64 GNU/Linux

Diagnostics:
There the errors that I see: :

0|api | root WARN Collided keybinding is ignored; {"command":"outlineView:toggle","keybinding":"ctrlcmd+shift+s"} collided with {"command":"file.saveAs","keybinding":"ctrl+shift+s"}
0|api | root WARN Could not register keybinding:
0|api | {"command":"outlineView:toggle","keybinding":"ctrlcmd+shift+s"}
0|api | Error: "ctrlcmd+shift+s" is in collision with something else [scope:0]
0|api | root WARN Collided keybinding is ignored; {"command":"passthrough","keybinding":"ctrl+k","context":"terminalActive"} collided with {"command":"terminal:clear","keybinding":"ctrlcmd+k","context":"terminalActive"}
0|api | root WARN Could not register keybinding:
0|api | {"command":"passthrough","keybinding":"ctrl+k","context":"terminalActive"}
0|api | Error: "ctrl+k" is in collision with something else [scope:0]
0|api | root WARN e.onStart is slow, took: 108.82500000298023 ms
0|api | root WARN e.onStart is slow, took: 1282.455000007758 ms
0|api | root ERROR Error(s) reading config file: file:///home/david/georq_workspace/.theia/tasks.json
0|api | root ERROR Couldn't resize terminal -1, because it doesn't exist.
0|api | root ERROR Couldn't resize terminal -1, because it doesn't exist.
0|api | terminal ERROR Couldn't attach - can't find terminal with id: 12
0|api | terminal ERROR Error attaching to terminal id 12, the terminal is most likely gone. Starting up a new terminal instead.

On the zsh environment it is a little more verbose:

Started watching: /home/david/src/map_workspace/.theia/tasks.json
task INFO Created new task, id: 0, process id: 10, OS PID: 14940, context: file:///home/david/src/map_workspace
terminal ERROR Couldn't attach - can't find terminal with id: 10
root ERROR Couldn't resize terminal -1, because it doesn't exist.
terminal ERROR Error attaching to terminal id 10, the terminal is most likely gone. Starting up a new terminal instead.

So clearly, the task extension cannot find the current terminal and then starts a new terminal, but doesn't run the task either way.

bug help wanted tasks

Most helpful comment

right, the output is not there.

It's a bug.

So I guess if I want to execute a python script programmatically I should just use the process extension.

If you don't want to show output to the end user, yes. If you want then tasks should be handy.

All 12 comments

A new terminal for a task is expected. Although it should be reused for executing the same task again. It is known issue.

From your gifs it looks like taks is actually not properly executed, i.e. output is not there, correct?

cc @elaihau @RomanNikitenko @vince-fugnitto

From your gifs it looks like taks is actually not properly executed, i.e. output is not there, correct?

right, the output is not there. So I guess if I want to execute a python script programmatically I should just use the process extension.

right, the output is not there.

It's a bug.

So I guess if I want to execute a python script programmatically I should just use the process extension.

If you don't want to show output to the end user, yes. If you want then tasks should be handy.

FYI, this is the extension version from yarn.lock

"@theia/task@^0.9.0":
resolved "https://registry.yarnpkg.com/@theia/task/-/task-0.9.0.tgz#751079605c95289ab71c3c43720bcf8634a8e310"

I believe it's a duplicate of the following issue https://github.com/theia-ide/theia/issues/2961

It looks like the output of short lived tasks are not properly outputted since they complete before a terminal can be created and initialized.

@vince-fugnitto some is going to look at it? i.e. @elaihau ? fixing such bugs is important for vscode support as well. Or should we mark it as help wanted?

@vince-fugnitto some is going to look at it? i.e. @elaihau ? fixing such bugs is important for vscode support as well. Or should we mark it as help wanted?

I can inform @elaihau about the bug and see if he wants to handle it. He's done some great improvements to the tasks system already.

I have encountered the same issue.

To replicate:

 protected getWorkspaceContext(): string | undefined {
        return this.workspaceService.workspace && this.workspaceService.workspace.uri;
    }

    async launchTask(arg:string): Promise<void> {

        const taskConfig: TaskConfiguration = {
            label: 'test runner',
            type: 'shell',
            command: '/path/to/testscript',
            options: {
                cwd: this.getWorkspaceContext()
            },
            _source: this.getWorkspaceContext(),
            args: [
                //arg
            ]
        };

        let taskInfo: TaskInfo;

        try {
            console.log('Executing this task');
            taskInfo = await this.taskServer.run(taskConfig);
            if (taskInfo.terminalId !== undefined) {
                console.log(taskInfo)
                this.logger.debug(`Task created: taskInfo: ${taskInfo}`);
                this.taskService.attach(taskInfo.terminalId, taskInfo.taskId);
            }
            console.log("SUCCESS!")
        } catch (error) {
            const errorStr = `Error launching task: ${error.message}`;
            this.logger.error(errorStr);
            return;
        }
    }

Example output:

task INFO Created new task, id: 5, process id: 16, OS PID: 49171, context: [object Object]
root INFO Executing this task
root INFO file:///path/to/somewhere
root INFO { taskId: 5,
  ctx: { _isCancelled: false },
  config: 
   { label: 'python runner',
     type: 'shell',
     command: '/path/to/testscript',
     options: { cwd: 'file:///path/to/somewhere', env: [Object] },
     _source: 'file:///path/to/somewhere',
     args: [] },
  terminalId: 16 }
root INFO SUCCESS!
terminal ERROR Couldn't attach - can't find terminal with id: 16 
terminal ERROR Error attaching to terminal id 16, the terminal is most likely gone. Starting up a new terminal instead.
root ERROR Couldn't resize terminal -1, because it doesn't exist.

What is most interesting is that the process that gets started when a task is created, has a PID on my system of +1 of the PID that is logged. So in this case 49171 is running as 49172: /bin/bash -l. The testscript path provided is never executed.

@elaihau @RomanNikitenko Was it resolved by https://github.com/eclipse-theia/theia/pull/6668?

@elaihau @RomanNikitenko Was it resolved by #6668?

I think not.

@akosyakov
I believe this issue and #6668 are unrelated, as this one is caused by "the short running task finishes running before being attached to the terminal".

@elaihau ok, do you know anyone is looking into https://github.com/eclipse-theia/theia/issues/2961?

It is not an easy change. From what I can remember Sven had a PR for it (not merged).
@marechal-p also looked at it but he had other priorities so didn't get the chance to invest much time on it.

Was this page helpful?
0 / 5 - 0 ratings