diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index e858f80bcc..fbb7a556a8 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 }[]; @@ -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(); } @@ -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 92c797d47f..aaedc24314 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,16 +156,18 @@ export async function deactivate() { async function bootstrap(config: Config, state: PersistentState): Promise { await fs.mkdir(config.globalStoragePath, { recursive: true }); + if (!config.currentExtensionIsNightly) { + await state.updateNightlyReleaseId(undefined); + } await bootstrapExtension(config, state); const path = await bootstrapServer(config, state); - return path; } async function bootstrapExtension(config: Config, state: PersistentState): Promise { if (config.package.releaseTag === null) return; if (config.channel === "stable") { - if (config.package.releaseTag === NIGHTLY_TAG) { + 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` @@ -176,27 +178,34 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi if (serverPath(config)) return; const now = Date.now(); - if (config.package.releaseTag === NIGHTLY_TAG) { + 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 = state.releaseId === undefined || (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 (state.releaseId === undefined) { // Show error only for the initial download - await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly ${e}`); + if (isInitialNightlyDownload) { + await vscode.window.showErrorMessage(`Failed to download rust-analyzer nightly: ${e}`); } - return undefined; + return; }); - if (release === undefined || release.id === state.releaseId) return; + if (latestNightlyRelease === undefined) { + if (isInitialNightlyDownload) { + await vscode.window.showErrorMessage("Failed to download rust-analyzer nightly: empty release contents returned"); + } + 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).", @@ -204,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"); @@ -221,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.updateReleaseId(release.id); + await state.updateNightlyReleaseId(latestNightlyRelease.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 afb6525899..dd2aeecca3 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,10 +21,10 @@ 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 | undefined) { await this.globalState.update("releaseId", value); } diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index 4212f90ca0..270719de76 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");