Skip to content
New issue

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

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

Already on GitHub? # to your account

[bug] unknown variant executeAndReturn, expected one of execute, stdinWrite, killChild, open #9786

Closed
zhyit opened this issue May 15, 2024 · 9 comments · Fixed by #9792
Closed
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@zhyit
Copy link

zhyit commented May 15, 2024

Describe the bug

const output = await new Command('echo', 'message').execute();
console.log('out: ',output)
调用execute时报的错误--- unknown variant executeAndReturn, expected one of execute, stdinWrite, killChild, open

Reproduction

image

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 124.0.2478.97
    ✔ MSVC: Visual Studio ���ɹ��� 2022
    ✔ rustc: 1.71.0 (8ede3aae2 2023-07-12)
    ✔ cargo: 1.71.0 (cfd3bbd8f 2023-06-08)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.13.1
    - pnpm: 8.15.7
    - npm: 8.3.0

[-] Packages
    - tauri [RUST]: 1.4.1
    - tauri-build [RUST]: 1.4.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: 1.5.5
    - @tauri-apps/cli [NPM]: 1.5.14

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

@zhyit zhyit added status: needs triage This issue needs to triage, applied to new issues type: bug labels May 15, 2024
@amrbashir
Copy link
Member

you'll need to update tauri in your Cargo.toml to 1.6.5 or use @tauri-apps/api version 1.5.4, seems like #9706 broke the compatibility in a patch version, I will release a new patches to fix that.

@amrbashir
Copy link
Member

problematic versions have been yanked and a new release has been made

@zhyit
Copy link
Author

zhyit commented May 16, 2024

you'll need to update tauri in your Cargo.toml to 1.6.5 or use @tauri-apps/api version 1.5.4, seems like #9706 broke the compatibility in a patch version, I will release a new patches to fix that.

I converted the version to 1.5.4, but still reported the same error,Do I need to modify anything else?
image

@amrbashir
Copy link
Member

the problematic versions have been yanked and deprecated. Try upgrading @tauri-apps/api to 1.5.6

@zhyit
Copy link
Author

zhyit commented May 17, 2024

the problematic versions have been yanked and deprecated. Try upgrading @tauri-apps/api to 1.5.6

I tried setting the version to 1.5.6, but still reported the same error
image

@amrbashir
Copy link
Member

please share a repro then

@zhyit
Copy link
Author

zhyit commented May 17, 2024

please share a repro then

interface BlockItem {
  appName: string,
  matchRegex: string
}

example: 
{
  appName: 'cmd',
  matchRegex: '.*cmd.*\.exe'
}

const appCheck = async (blocklist?: BlockItem[]): Promise<string> => {
        if (!blocklist) return "";
        // 检测运行中的程序
        const result = await new Command('tasklist', [
            "/SVC", "/FO", "CSV", "/NH", "/FI", "Status eq RUNNING"], {
            encoding: "gbk"
        }).execute();
        if (!result.stdout) return "";
        let list = result.stdout.split("\r\n");
        if (list.length < 1) {
            list = result.stdout.split("\n");
        }
        let founds: Map<string, string> = new Map();
        for (let one of list) {
            const row = one.split("\",");
            // 映像名称
            const image = row[0].replaceAll("\"", "");
            for (let item of blocklist) {
                if (founds.has(item.matchRegex)) continue;
                if (image.match(item.matchRegex)) {
                    founds.set(item.matchRegex, item.appName);
                    break
                }
            }
        }
        return [...founds.values()].join(",");
    }

@amrbashir
Copy link
Member

Please upload a full repo that has the issue, as I can't reproduce with a fresh tauri app

@antoinebarbier022
Copy link

I had the same error and I have solved this problem with "cargo update"

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants