diff --git a/src/client/activation/jedi/manager.ts b/src/client/activation/jedi/manager.ts index 1b00061b6f82..0238fa5d1d76 100644 --- a/src/client/activation/jedi/manager.ts +++ b/src/client/activation/jedi/manager.ts @@ -7,7 +7,7 @@ import '../../common/extensions'; import { inject, injectable, named } from 'inversify'; import { ICommandManager } from '../../common/application/types'; -import { traceDecorators } from '../../common/logger'; +import { traceDecorators, traceVerbose } from '../../common/logger'; import { IDisposable, Resource } from '../../common/types'; import { debounceSync } from '../../common/utils/decorators'; import { EXTENSION_ROOT_DIR } from '../../constants'; @@ -80,16 +80,22 @@ export class JediLanguageServerManager implements ILanguageServerManager { this.interpreter = interpreter; this.analysisOptions.onDidChange(this.restartLanguageServerDebounced, this, this.disposables); - // Version is actually hardcoded in our requirements.txt. - const requirementsTxt = await fs.readFile(path.join(EXTENSION_ROOT_DIR, 'requirements.txt'), 'utf-8'); - - // Search using a regex in the text - const match = /jedi-language-server==([0-9\.]*)/.exec(requirementsTxt); - if (match && match.length > 1) { - // eslint-disable-next-line prefer-destructuring - this.lsVersion = match[1]; - } else { - this.lsVersion = '0.19.3'; + try { + // Version is actually hardcoded in our requirements.txt. + const requirementsTxt = await fs.readFile( + path.join(EXTENSION_ROOT_DIR, 'jedils_requirements.txt'), + 'utf-8', + ); + + // Search using a regex in the text + const match = /jedi-language-server==([0-9\.]*)/.exec(requirementsTxt); + if (match && match.length === 2) { + [, this.lsVersion] = match; + } + } catch (ex) { + // Getting version here is best effort and does not affect how LS works and + // failing to get version should not stop LS from working. + traceVerbose('Failed to get jedi-language-server version: ', ex); } await this.analysisOptions.initialize(resource, interpreter);