Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

execChildProcess does not work with wsl #247

Closed
kdy1 opened this issue Feb 2, 2018 · 4 comments
Closed

execChildProcess does not work with wsl #247

kdy1 opened this issue Feb 2, 2018 · 4 comments

Comments

@kdy1
Copy link
Contributor

kdy1 commented Feb 2, 2018

https://github.com/rust-lang-nursery/rls-vscode/blob/5afe3bbe5b6cf538cafea9bf8bfe3b3779026041/src/utils/child_process.ts#L25-L40

For native windows binaries, this works well. But when wsl is involved (even if it's subprocess invoked from simple windows exe file) returned promise does not resolve because callback passed to child_process.exec isn't called. I'm not sure if this is an issue of rls-vscode, but this can be workarounded.

Also, I'm sure that command itself is invoked, because stdout is set to nightly-x86_64-unknown-linux-gnu (default) if I set timeout. (but timeout error occurs)


When I modify definition like below and invocations, it works.

export async function execChildProcess(command: string, args: string[]): Promise<ExecChildProcessResult> {
    // FIXME: async
    const child = child_process.spawnSync(
        command, args, { encoding: 'utf8' },
    );

    if (child.error) {
        throw new Error(`Error running `${command}`: ${child.error}`);
    }

    if (child.status > 0) {
        throw new Error(`Error getting sysroot from `${command}`: exited with \`${child.status}\``);
    }

    if (!child.stdout || typeof child.stdout.toString !== 'function') {
        throw new Error(`Couldn't get sysroot from `${command}`: Got no ouput`);
    }

    return {
        stdout: child.stdout,
        stderr: child.stderr,
    };
}

So.. child_process.execseems like a root of issue. This should be replaced withchild_process.spawn` to work with wsl.

@yisonPylkita
Copy link
Contributor

Yep, you are right. GH-335 will fix this issue

@yisonPylkita
Copy link
Contributor

#488 was merged a few days ago. Thus this bug should be fixed.

Do you mind running this extension from master to confirm the fix ?

@kdy1
Copy link
Contributor Author

kdy1 commented Mar 9, 2019

@yisonPylkita I uninstalled wsl for some reasons. So I can't.

@Xanewok
Copy link
Member

Xanewok commented Apr 7, 2019

This was done as part of the 0.6 refactor, closing this now.

@Xanewok Xanewok closed this as completed Apr 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants