microsoft / vscode-test

Testing utility for VS Code extensions
MIT License
246 stars 59 forks source link

Incorrect installation path when using `downloadAndUnzipVSCode` in versions 1.85.0 and above #255

Closed umpox closed 10 months ago

umpox commented 10 months ago

There seems to have been a regression somewhere with how resolveCliArgsFromVSCodeExecutablePath either downloads VS Code, or returns the correct CLI path. It is missing Visual Studio Code.app from the installation path.

Before (pre 1.85.0)

const vscodeExecutablePath = await downloadAndUnzipVSCode({ version: '1.84.0' }) Download location: .vscode-test/vscode-darwin-arm64-1.84.0/Visual Studio Code.app/Contents/Resources/app/bin/code

After (1.85.0 and after)

const vscodeExecutablePath = await downloadAndUnzipVSCode({ version: '1.85.0' }) Download location :.vscode-test/vscode-darwin-arm64-1.85.0/Contents/Resources/app/bin/code

resolveCliArgsFromVSCodeExecutablePath still expects "Visual Studio Code.app" in the path.

This causes the error: .vscode-test/vscode-darwin-arm64-1.85.1/Visual Studio Code.app/Contents/Resources/app/bin/code: No such file or directory

umpox commented 10 months ago

Example code that errors:

import { exec } from 'child_process';

import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath } from '@vscode/test-electron';

async function main() {
    const vscodeExecutablePath = await downloadAndUnzipVSCode({ version: '1.85.0' })
    const [cli] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath)

    // Run a test message to check CLI works
    exec(`"${cli}" --version`, (error, stdout, stderr) => {
        if (error) {
            console.error(`error: ${error.message}`);
            return;
        }
        if (stderr) {
            console.error(`stderr: ${stderr}`);
            return;
        }
        console.log(`stdout: ${stdout}`);
    });
}

main()
rtetley commented 10 months ago

Do you get passed the download stage ? For me this:

const vscodeExecutablePath = await downloadAndUnzipVSCode('1.85.0');

Causes the error:

Downloading VS Code 1.85.0 from https://update.code.visualstudio.com/1.85.0/darwin-arm64/stable
gzip: stdin has more than one entry--rest ignored
tar: Child died with signal 13
tar: Error is not recoverable: exiting now
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
Emitted 'error' event on Socket instance at:
    at Socket.onerror (node:internal/streams/readable:785:14)
    at Socket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

No problem if I use version 1.84.0 though

connor4312 commented 10 months ago

Please upgrade to the latest version of @vscode/test-electron where this is fixed.