flix / vscode-flix

Apache License 2.0
20 stars 22 forks source link

Activating extension flix.flix failed due to an error: Illegal argument: base #214

Closed michaellilltokiwa closed 1 year ago

michaellilltokiwa commented 2 years ago

The extension does not activate for me, here is the error:

[2022-07-28 14:41:46.533] [exthost] [error] Activating extension flix.flix failed due to an error:
[2022-07-28 14:41:46.533] [exthost] [error] Error: Illegal argument: base
    at I (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:7:1279)
    at new kt (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:78:118034)
    at new kt (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:78:86738)
    at Object.<anonymous> (/home/sam/.vscode/extensions/flix.flix-0.77.0/client/out/extension.js:25:29)
    at Module.u._compile (/snap/code/101/usr/share/code/resources/app/out/vs/loader.js:4:1313)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1216:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at Module._load (node:internal/modules/cjs/loader:876:12)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
    at Function.i._load (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:32133)
    at Function.v._load (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:28715)
    at Function.b._load (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:106:61601)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Function.r [as __$__nodeRequire] (/snap/code/101/usr/share/code/resources/app/out/vs/loader.js:5:101)
    at w._loadCommonJSModule (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:30173)
    at w._doActivateExtension (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:97:14758)
    at w._activateExtension (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:97:13706)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async b._activate (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:8180)
    at async b._waitForDepsThenActivate (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:85:8122)
    at async b._initialize (/snap/code/101/usr/share/code/resources/app/out/vs/workbench/api/node
magnus-madsen commented 2 years ago

Hmm. Never seen that before. What OS and Java version do you have?

michaellilltokiwa commented 2 years ago

Nothing special, Ubuntu 22.04:


sam@sam-Standard-PC-Q35-ICH9-2009:~$ code --version
1.69.1
b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a
x64
sam@sam-Standard-PC-Q35-ICH9-2009:~$ uname -a
Linux sam-Standard-PC-Q35-ICH9-2009 5.15.0-41-generic #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
sam@sam-Standard-PC-Q35-ICH9-2009:~$ java --version
openjdk 17.0.3 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 17.0.3+7-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)
magnus-madsen commented 2 years ago

I don't really recognize anything in the stack trace. Could you try to paste some of the content of:

/home/sam/.vscode/extensions/flix.flix-0.77.0/client/out/extension.js:25:29

near line 25.

michaellilltokiwa commented 2 years ago

extension.js

"use strict";
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });
exports.deactivate = exports.activate = exports.JAR_GLOB_PATTERN = exports.FPKG_GLOB_PATTERN = exports.FLIX_GLOB_PATTERN = exports.defaultLaunchOptions = void 0;
const vscode = require("vscode");
const jobs = require("./engine/jobs");
const ensureTargetWritable_1 = require("./util/ensureTargetWritable");
const ensureFlixExists_1 = require("./util/ensureFlixExists");
const createLanguageClient_1 = require("./util/createLanguageClient");
const showStartupProgress_1 = require("./util/showStartupProgress");
const eventEmitter_1 = require("./services/eventEmitter");
const state_1 = require("./services/state");
const handlers = require("./handlers");
const timers_1 = require("./services/timers");
const releaseVirtualDocument_1 = require("./services/releaseVirtualDocument");
const _ = require('lodash/fp');
exports.defaultLaunchOptions = {
    shouldUpdateFlix: false
};
let client;
let flixWatcher;
let pkgWatcher;
const extensionObject = vscode.extensions.getExtension('flix.flix');
exports.FLIX_GLOB_PATTERN = '**/*.flix';
exports.FPKG_GLOB_PATTERN = new vscode.RelativePattern((_a = vscode.workspace.workspaceFolders) === null || _a === void 0 ? void 0 : _a[0], 'lib/**/*.fpkg');
exports.JAR_GLOB_PATTERN = new vscode.RelativePattern((_b = vscode.workspace.workspaceFolders) === null || _b === void 0 ? void 0 : _b[0], 'lib/**/*.jar');
let outputChannel;
// flag to keep track of whether errors were present last time we ran diagnostics
let diagnosticsErrors = false;
/**
 * Convert URI to file scheme URI shared by e.g. TextDocument's URI.
 *
 * @param uri {vscode.Uri}
 */
function vsCodeUriToUriString(uri) {
    return vscode.Uri.file(uri.path).toString(false);
}
function makeHandleRestartClient(context, launchOptions) {
    return async function handleRestartClient() {
        (0, timers_1.callResolversAndEmptyList)();
        await startSession(context, launchOptions, client);
    };
}
function getUserConfiguration() {
    return vscode.workspace.getConfiguration('flix');
}
function handlePrintDiagnostics({ status, result }) {
    if (status === 'success') {
        if (diagnosticsErrors) {
            outputChannel.clear();
            diagnosticsErrors = false;
        }
    }
    else {
        outputChannel.clear();
        diagnosticsErrors = true;
        for (const res of result) {
            for (const diag of res.diagnostics) {
                if (diag.severity <= 2) {
                    outputChannel.appendLine(`${String.fromCodePoint(0x274C)} ${diag.fullMessage}`);
                }
            }
        }
    }
}
async function activate(context, launchOptions = exports.defaultLaunchOptions) {
    // activate state
    (0, state_1.default)(context);
    (0, releaseVirtualDocument_1.registerFlixReleaseDocumentProvider)(context);
    // create output channels
    outputChannel = vscode.window.createOutputChannel('Flix Compiler');
    // create language client
    client = (0, createLanguageClient_1.default)({ context, outputChannel });
    // Start the client. This will also launch the server
    await client.start();
    // Utility for safely registering commands
    const registeredCommands = await vscode.commands.getCommands(true);
    const registerCommand = (command, callback) => {
        if (!_.includes(command, registeredCommands)) {
            vscode.commands.registerCommand(command, callback);
        }
    };
    // Register commands for command palette
    registerCommand('flix.internalRestart', makeHandleRestartClient(context, { shouldUpdateFlix: false }));
    registerCommand('flix.internalDownloadLatest', makeHandleRestartClient(context, { shouldUpdateFlix: true }));
    registerCommand('flix.runMain', handlers.runMain(context, launchOptions));
    registerCommand('flix.runMainWithArgs', handlers.runMainWithArgs(context, launchOptions));
    registerCommand('flix.runMainNewTerminal', handlers.runMainNewTerminal(context, launchOptions));
    registerCommand('flix.runMainNewTerminalWithArgs', handlers.runMainNewTerminalWithArgs(context, launchOptions));
    registerCommand('flix.cmdInit', handlers.cmdInit(context, launchOptions));
    registerCommand('flix.cmdCheck', handlers.cmdCheck(context, launchOptions));
    registerCommand('flix.cmdBuild', handlers.cmdBuild(context, launchOptions));
    registerCommand('flix.cmdBuildJar', handlers.cmdBuildJar(context, launchOptions));
    registerCommand('flix.cmdBuildPkg', handlers.cmdBuildPkg(context, launchOptions));
    registerCommand('flix.cmdRunProject', handlers.cmdRunProject(context, launchOptions));
    registerCommand('flix.cmdBenchmark', handlers.cmdBenchmark(context, launchOptions));
    registerCommand('flix.cmdTests', handlers.cmdTests(context, launchOptions));
    registerCommand('flix.cmdTestWithFilter', handlers.cmdTestWithFilter(context, launchOptions));
    registerCommand('flix.cmdRepl', handlers.cmdRepl(context, launchOptions));
    // watch for changes on the file system (delete, create, rename .flix files)
    flixWatcher = vscode.workspace.createFileSystemWatcher(exports.FLIX_GLOB_PATTERN);
    flixWatcher.onDidDelete((vsCodeUri) => {
        const uri = vsCodeUriToUriString(vsCodeUri);
        client.sendNotification(jobs.Request.apiRemUri, { uri });
    });
    flixWatcher.onDidCreate((vsCodeUri) => {
        const uri = vsCodeUriToUriString(vsCodeUri);
        client.sendNotification(jobs.Request.apiAddUri, { uri });
    });
    // watch for changes on the file system (delete, create .fpkg files)
    pkgWatcher = vscode.workspace.createFileSystemWatcher(exports.FPKG_GLOB_PATTERN);
    pkgWatcher.onDidDelete((vsCodeUri) => {
        const uri = vsCodeUriToUriString(vsCodeUri);
        client.sendNotification(jobs.Request.apiRemPkg, { uri });
    });
    pkgWatcher.onDidCreate((vsCodeUri) => {
        const uri = vsCodeUriToUriString(vsCodeUri);
        client.sendNotification(jobs.Request.apiAddPkg, { uri });
    });
    // watch for changes on the file system (delete, create .jar files)
    pkgWatcher = vscode.workspace.createFileSystemWatcher(exports.JAR_GLOB_PATTERN);
    pkgWatcher.onDidDelete((vsCodeUri) => {
        const uri = vsCodeUriToUriString(vsCodeUri);
        client.sendNotification(jobs.Request.apiRemJar, { uri });
    });
    pkgWatcher.onDidCreate((vsCodeUri) => {
        const uri = vsCodeUriToUriString(vsCodeUri);
        client.sendNotification(jobs.Request.apiAddJar, { uri });
    });
    vscode.workspace.onDidChangeConfiguration(() => {
        client.sendNotification(jobs.Request.internalReplaceConfiguration, getUserConfiguration());
    });
    await startSession(context, launchOptions, client);
}
exports.activate = activate;
async function startSession(context, launchOptions = exports.defaultLaunchOptions, client) {
    // clear listeners from previous sessions
    eventEmitter_1.default.removeAllListeners();
    // clear outputs
    outputChannel.clear();
    // show default output channel without changing focus
    outputChannel.show(true);
    const globalStoragePath = context.globalStoragePath;
    const workspaceFolders = _.map(_.flow(_.get('uri'), _.get('fsPath')), vscode.workspace.workspaceFolders);
    const workspaceFiles = _.map(vsCodeUriToUriString, (await vscode.workspace.findFiles(exports.FLIX_GLOB_PATTERN)));
    const workspacePkgs = _.map(vsCodeUriToUriString, (await vscode.workspace.findFiles(exports.FPKG_GLOB_PATTERN)));
    const workspaceJars = _.map(vsCodeUriToUriString, (await vscode.workspace.findFiles(exports.JAR_GLOB_PATTERN)));
    // Make sure we can write to `./target`
    if (!(0, ensureTargetWritable_1.default)(_.first(workspaceFolders))) {
        throw new Error('Cannot write to "target" folder.');
    }
    // Wait until we're sure flix exists
    const flixFilename = await (0, ensureFlixExists_1.default)({ globalStoragePath, workspaceFolders, shouldUpdateFlix: launchOptions.shouldUpdateFlix });
    // Show a startup progress that times out after 10 (default) seconds
    (0, showStartupProgress_1.default)();
    // Send start notification to the server which actually starts the Flix compiler
    client.sendNotification(jobs.Request.internalReady, {
        flixFilename,
        workspaceFolders,
        extensionPath: extensionObject.extensionPath || context.extensionPath,
        extensionVersion: extensionObject.packageJSON.version,
        globalStoragePath: context.globalStoragePath,
        workspaceFiles,
        workspacePkgs,
        workspaceJars,
        userConfiguration: getUserConfiguration()
    });
    // Handle when server has answered back after getting the notification above
    client.onNotification(jobs.Request.internalReady, function handler() {
        // waits for server to answer back after having started successfully
        eventEmitter_1.default.emit(jobs.Request.internalReady);
    });
    client.onNotification(jobs.Request.internalFinishedJob, function handler() {
        // only one job runs at once, so currently not trying to distinguish
        eventEmitter_1.default.emit(jobs.Request.internalFinishedJob);
    });
    client.onNotification(jobs.Request.internalDiagnostics, handlePrintDiagnostics);
    client.onNotification(jobs.Request.internalRestart, makeHandleRestartClient(context));
    client.onNotification(jobs.Request.internalMessage, vscode.window.showInformationMessage);
    client.onNotification(jobs.Request.internalError, vscode.window.showErrorMessage);
}
function deactivate() {
    flixWatcher && flixWatcher.dispose();
    pkgWatcher && pkgWatcher.dispose();
    outputChannel && outputChannel.dispose();
    return client ? client.stop() : undefined;
}
exports.deactivate = deactivate;
//# sourceMappingURL=extension.js.map
magnus-madsen commented 2 years ago

Hmm. Nothing really springs to mind.

magnus-madsen commented 2 years ago

@nicdard @mlutze Any ideas?

michaellilltokiwa commented 2 years ago

@magnus-madsen I think I understand now how the reproduce the issue. Open just a flix file in vscode, no workspace, no folder.

magnus-madsen commented 2 years ago

Oh. I'll try it when I'm on the computer. Does it work with a project folder?

michaellilltokiwa commented 2 years ago

@magnus-madsen yes, the extension activates with a project folder. I have some other issues now that I do not yet understand where the extension complains about duplicate names in the flix code.