From b8635a8e6096768a5f2e382bed4af255896968f1 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 23 May 2021 11:28:06 +0300 Subject: Download nightly extension when configured and run from stable extension version --- editors/code/src/main.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 92c797d47..ee2c50dc7 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -192,11 +192,18 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi }).catch(async (e) => { log.error(e); if (state.releaseId === undefined) { // Show error only for the initial download - await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`); + await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly: ${e}`); } - return undefined; + return; }); - if (release === undefined || release.id === state.releaseId) return; + if (release === undefined) { + if (state.releaseId === undefined) { // Show error only for the initial download + await vscode.window.showErrorMessage("Failed to download rust-analyzer nightly: empty release contents returned"); + } + return; + } + // If currently used extension is nightly and its release id matches the downloaded release id, we're already on the latest nightly version + if (config.package.releaseTag === NIGHTLY_TAG && release.id === state.releaseId) return; const userResponse = await vscode.window.showInformationMessage( "New version of rust-analyzer (nightly) is available (requires reload).", -- cgit v1.2.3 From be3e997ddffbcfb6c75fce47c803c7abd50ef21c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 23 May 2021 11:49:34 +0300 Subject: Remove nightly release id from local storage for stable extensions --- editors/code/src/main.ts | 4 +++- editors/code/src/persistent_state.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index ee2c50dc7..5db66df93 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -156,9 +156,11 @@ export async function deactivate() { async function bootstrap(config: Config, state: PersistentState): Promise { await fs.mkdir(config.globalStoragePath, { recursive: true }); + if (config.package.releaseTag != NIGHTLY_TAG) { + await state.removeReleaseId(); + } await bootstrapExtension(config, state); const path = await bootstrapServer(config, state); - return path; } diff --git a/editors/code/src/persistent_state.ts b/editors/code/src/persistent_state.ts index afb652589..2519bd77a 100644 --- a/editors/code/src/persistent_state.ts +++ b/editors/code/src/persistent_state.ts @@ -27,6 +27,9 @@ export class PersistentState { async updateReleaseId(value: number) { await this.globalState.update("releaseId", value); } + async removeReleaseId() { + await this.globalState.update("releaseId", undefined); + } /** * Version of the extension that installed the server. -- cgit v1.2.3 From 230ed3304a8acc84ffab36dd9e6d0ebc0f4d054d Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 23 May 2021 11:51:35 +0300 Subject: Better releaseId naming --- editors/code/src/main.ts | 13 ++++++------- editors/code/src/persistent_state.ts | 10 +++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 5db66df93..6ed8b6146 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -157,7 +157,7 @@ async function bootstrap(config: Config, state: PersistentState): Promise anHour; + const shouldCheckForNewNightly = state.nightlyReleaseId === undefined || (now - (lastCheck ?? 0)) > anHour; if (!shouldCheckForNewNightly) return; } @@ -193,19 +193,18 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi return await fetchRelease("nightly", state.githubToken, config.httpProxy); }).catch(async (e) => { log.error(e); - if (state.releaseId === undefined) { // Show error only for the initial download + if (state.nightlyReleaseId === undefined) { // Show error only for the initial download await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly: ${e}`); } return; }); if (release === undefined) { - if (state.releaseId === undefined) { // Show error only for the initial download + if (state.nightlyReleaseId === undefined) { // Show error only for the initial download await vscode.window.showErrorMessage("Failed to download rust-analyzer nightly: empty release contents returned"); } return; } - // If currently used extension is nightly and its release id matches the downloaded release id, we're already on the latest nightly version - if (config.package.releaseTag === NIGHTLY_TAG && release.id === state.releaseId) return; + if (config.package.releaseTag === NIGHTLY_TAG && release.id === state.nightlyReleaseId) return; const userResponse = await vscode.window.showInformationMessage( "New version of rust-analyzer (nightly) is available (requires reload).", @@ -230,7 +229,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest)); await fs.unlink(dest); - await state.updateReleaseId(release.id); + await state.updateNightlyReleaseId(release.id); await state.updateLastCheck(now); await vscode.commands.executeCommand("workbench.action.reloadWindow"); } diff --git a/editors/code/src/persistent_state.ts b/editors/code/src/persistent_state.ts index 2519bd77a..c02eb2ca3 100644 --- a/editors/code/src/persistent_state.ts +++ b/editors/code/src/persistent_state.ts @@ -3,8 +3,8 @@ import { log } from './util'; export class PersistentState { constructor(private readonly globalState: vscode.Memento) { - const { lastCheck, releaseId, serverVersion } = this; - log.info("PersistentState:", { lastCheck, releaseId, serverVersion }); + const { lastCheck, nightlyReleaseId, serverVersion } = this; + log.info("PersistentState:", { lastCheck, nightlyReleaseId, serverVersion }); } /** @@ -21,13 +21,13 @@ export class PersistentState { * Release id of the *nightly* extension. * Used to check if we should update. */ - get releaseId(): number | undefined { + get nightlyReleaseId(): number | undefined { return this.globalState.get("releaseId"); } - async updateReleaseId(value: number) { + async updateNightlyReleaseId(value: number) { await this.globalState.update("releaseId", value); } - async removeReleaseId() { + async removeNightlyReleaseId() { await this.globalState.update("releaseId", undefined); } -- cgit v1.2.3 From 95c51d8f1df1efdb2e98b7717544a6db8cad14e7 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 23 May 2021 11:54:03 +0300 Subject: Don't use a deprecated accessor --- editors/code/src/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index e858f80bc..c9249768d 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -34,7 +34,7 @@ export class Config { readonly globalStoragePath: string; constructor(ctx: vscode.ExtensionContext) { - this.globalStoragePath = ctx.globalStoragePath; + this.globalStoragePath = ctx.globalStorageUri.path; vscode.workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, ctx.subscriptions); this.refreshLogging(); } -- cgit v1.2.3 From 223dbd2187e5b966d192dac9745d47831dccb9b3 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 23 May 2021 13:17:09 +0300 Subject: Style fix --- editors/code/src/main.ts | 18 ++++++++++-------- editors/code/src/persistent_state.ts | 5 +---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 6ed8b6146..a6c1c0906 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -156,8 +156,8 @@ export async function deactivate() { async function bootstrap(config: Config, state: PersistentState): Promise { await fs.mkdir(config.globalStoragePath, { recursive: true }); - if (config.package.releaseTag != NIGHTLY_TAG) { - await state.removeNightlyReleaseId(); + if (config.package.releaseTag !== NIGHTLY_TAG) { + await state.updateNightlyReleaseId(undefined); } await bootstrapExtension(config, state); const path = await bootstrapServer(config, state); @@ -166,8 +166,9 @@ async function bootstrap(config: Config, state: PersistentState): Promise { if (config.package.releaseTag === null) return; + const currentExtensionIsNightly = config.package.releaseTag === NIGHTLY_TAG; if (config.channel === "stable") { - if (config.package.releaseTag === NIGHTLY_TAG) { + if (currentExtensionIsNightly) { void vscode.window.showWarningMessage( `You are running a nightly version of rust-analyzer extension. ` + `To switch to stable, uninstall the extension and re-install it from the marketplace` @@ -178,13 +179,14 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi if (serverPath(config)) return; const now = Date.now(); - if (config.package.releaseTag === NIGHTLY_TAG) { + const isInitialDownload = state.nightlyReleaseId === undefined; + if (currentExtensionIsNightly) { // Check if we should poll github api for the new nightly version // if we haven't done it during the past hour const lastCheck = state.lastCheck; const anHour = 60 * 60 * 1000; - const shouldCheckForNewNightly = state.nightlyReleaseId === undefined || (now - (lastCheck ?? 0)) > anHour; + const shouldCheckForNewNightly = isInitialDownload || (now - (lastCheck ?? 0)) > anHour; if (!shouldCheckForNewNightly) return; } @@ -193,18 +195,18 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi return await fetchRelease("nightly", state.githubToken, config.httpProxy); }).catch(async (e) => { log.error(e); - if (state.nightlyReleaseId === undefined) { // Show error only for the initial download + if (isInitialDownload) { await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly: ${e}`); } return; }); if (release === undefined) { - if (state.nightlyReleaseId === undefined) { // Show error only for the initial download + if (isInitialDownload) { await vscode.window.showErrorMessage("Failed to download rust-analyzer nightly: empty release contents returned"); } return; } - if (config.package.releaseTag === NIGHTLY_TAG && release.id === state.nightlyReleaseId) return; + if (currentExtensionIsNightly && release.id === state.nightlyReleaseId) return; const userResponse = await vscode.window.showInformationMessage( "New version of rust-analyzer (nightly) is available (requires reload).", diff --git a/editors/code/src/persistent_state.ts b/editors/code/src/persistent_state.ts index c02eb2ca3..dd2aeecca 100644 --- a/editors/code/src/persistent_state.ts +++ b/editors/code/src/persistent_state.ts @@ -24,12 +24,9 @@ export class PersistentState { get nightlyReleaseId(): number | undefined { return this.globalState.get("releaseId"); } - async updateNightlyReleaseId(value: number) { + async updateNightlyReleaseId(value: number | undefined) { await this.globalState.update("releaseId", value); } - async removeNightlyReleaseId() { - await this.globalState.update("releaseId", undefined); - } /** * Version of the extension that installed the server. -- cgit v1.2.3 From daedcc2b77187486fde13a2813809b06b2385ac0 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 23 May 2021 13:57:04 +0300 Subject: More style fixes --- editors/code/src/config.ts | 6 +++++- editors/code/src/main.ts | 29 ++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index c9249768d..fbb7a556a 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -4,7 +4,7 @@ import { log } from "./util"; export type UpdatesChannel = "stable" | "nightly"; -export const NIGHTLY_TAG = "nightly"; +const NIGHTLY_TAG = "nightly"; export type RunnableEnvCfg = undefined | Record | { mask?: string; env: Record }[]; @@ -170,4 +170,8 @@ export class Config { gotoTypeDef: this.get("hoverActions.gotoTypeDef"), }; } + + get currentExtensionIsNightly() { + return this.package.releaseTag === NIGHTLY_TAG; + } } diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index a6c1c0906..aaedc2431 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -6,7 +6,7 @@ import { promises as fs, PathLike } from "fs"; import * as commands from './commands'; import { activateInlayHints } from './inlay_hints'; import { Ctx } from './ctx'; -import { Config, NIGHTLY_TAG } from './config'; +import { Config } from './config'; import { log, assert, isValidExecutable } from './util'; import { PersistentState } from './persistent_state'; import { fetchRelease, download } from './net'; @@ -156,7 +156,7 @@ export async function deactivate() { async function bootstrap(config: Config, state: PersistentState): Promise { await fs.mkdir(config.globalStoragePath, { recursive: true }); - if (config.package.releaseTag !== NIGHTLY_TAG) { + if (!config.currentExtensionIsNightly) { await state.updateNightlyReleaseId(undefined); } await bootstrapExtension(config, state); @@ -166,9 +166,8 @@ async function bootstrap(config: Config, state: PersistentState): Promise { if (config.package.releaseTag === null) return; - const currentExtensionIsNightly = config.package.releaseTag === NIGHTLY_TAG; if (config.channel === "stable") { - if (currentExtensionIsNightly) { + if (config.currentExtensionIsNightly) { void vscode.window.showWarningMessage( `You are running a nightly version of rust-analyzer extension. ` + `To switch to stable, uninstall the extension and re-install it from the marketplace` @@ -179,34 +178,34 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi if (serverPath(config)) return; const now = Date.now(); - const isInitialDownload = state.nightlyReleaseId === undefined; - if (currentExtensionIsNightly) { + const isInitialNightlyDownload = state.nightlyReleaseId === undefined; + if (config.currentExtensionIsNightly) { // Check if we should poll github api for the new nightly version // if we haven't done it during the past hour const lastCheck = state.lastCheck; const anHour = 60 * 60 * 1000; - const shouldCheckForNewNightly = isInitialDownload || (now - (lastCheck ?? 0)) > anHour; + const shouldCheckForNewNightly = isInitialNightlyDownload || (now - (lastCheck ?? 0)) > anHour; if (!shouldCheckForNewNightly) return; } - const release = await downloadWithRetryDialog(state, async () => { + const latestNightlyRelease = await downloadWithRetryDialog(state, async () => { return await fetchRelease("nightly", state.githubToken, config.httpProxy); }).catch(async (e) => { log.error(e); - if (isInitialDownload) { + if (isInitialNightlyDownload) { await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly: ${e}`); } return; }); - if (release === undefined) { - if (isInitialDownload) { + if (latestNightlyRelease === undefined) { + if (isInitialNightlyDownload) { await vscode.window.showErrorMessage("Failed to download rust-analyzer nightly: empty release contents returned"); } return; } - if (currentExtensionIsNightly && release.id === state.nightlyReleaseId) return; + if (config.currentExtensionIsNightly && latestNightlyRelease.id === state.nightlyReleaseId) return; const userResponse = await vscode.window.showInformationMessage( "New version of rust-analyzer (nightly) is available (requires reload).", @@ -214,8 +213,8 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi ); if (userResponse !== "Update") return; - const artifact = release.assets.find(artifact => artifact.name === "rust-analyzer.vsix"); - assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); + const artifact = latestNightlyRelease.assets.find(artifact => artifact.name === "rust-analyzer.vsix"); + assert(!!artifact, `Bad release: ${JSON.stringify(latestNightlyRelease)}`); const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix"); @@ -231,7 +230,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest)); await fs.unlink(dest); - await state.updateNightlyReleaseId(release.id); + await state.updateNightlyReleaseId(latestNightlyRelease.id); await state.updateLastCheck(now); await vscode.commands.executeCommand("workbench.action.reloadWindow"); } -- cgit v1.2.3 From 9f9c4bf3de79ea22bd122574654d5f9f2066c3f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 23 May 2021 14:06:25 +0300 Subject: internal: disable debug symbols due to failing windows build See https://github.com/rust-lang/rust/issues/85598 --- xtask/src/dist.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index 4212f90ca..270719de7 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs @@ -67,7 +67,12 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> { fn dist_server(release_channel: &str) -> Result<()> { let _e = pushenv("RUST_ANALYZER_CHANNEL", release_channel); let _e = pushenv("CARGO_PROFILE_RELEASE_LTO", "true"); - let _e = pushenv("CARGO_PROFILE_RELEASE_DEBUG", "1"); + + // We want do enable debug symbols, but this causes our windows CI to fail: + // https://github.com/rust-lang/rust/issues/85598 + // + // let _e = pushenv("CARGO_PROFILE_RELEASE_DEBUG", "1"); + let target = get_target(); if target.contains("-linux-gnu") || target.contains("-linux-musl") { env::set_var("CC", "clang"); -- cgit v1.2.3