Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@theia/task Doesn't run task, creates new terminal #5825

Open
shortwavedave opened this issue Jul 31, 2019 · 12 comments
Open

@theia/task Doesn't run task, creates new terminal #5825

shortwavedave opened this issue Jul 31, 2019 · 12 comments
Labels
bug bugs found in the application help wanted issues meant to be picked up, require help tasks issues related to the task system

Comments

@shortwavedave
Copy link

shortwavedave commented Jul 31, 2019

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.

@akosyakov
Copy link
Member

akosyakov commented Jul 31, 2019

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

@akosyakov akosyakov added bug bugs found in the application tasks issues related to the task system labels Jul 31, 2019
@shortwavedave
Copy link
Author

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.

@akosyakov
Copy link
Member

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.

@shortwavedave
Copy link
Author

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"

@vince-fugnitto
Copy link
Member

I believe it's a duplicate of the following issue #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.

@akosyakov
Copy link
Member

@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
Copy link
Member

@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.

@eiso
Copy link

eiso commented Aug 3, 2019

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.

@akosyakov
Copy link
Member

@elaihau @RomanNikitenko Was it resolved by #6668?

@akosyakov akosyakov added the help wanted issues meant to be picked up, require help label Dec 16, 2019
@elaihau
Copy link
Contributor

elaihau commented Dec 16, 2019

@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".

@akosyakov
Copy link
Member

@elaihau ok, do you know anyone is looking into #2961?

@elaihau
Copy link
Contributor

elaihau commented Dec 16, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application help wanted issues meant to be picked up, require help tasks issues related to the task system
Projects
None yet
Development

No branches or pull requests

5 participants