Skip to content

Temporarily switch to node FS apis in KnownPathsService #11340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/10850.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use node FS APIs when searching for python. This is a temporary change until VSC FS APIs are fixed.
8 changes: 6 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/client/interpreter/locators/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as fsapi from 'fs-extra';
import { inject, injectable } from 'inversify';
import * as path from 'path';
import { traceError } from '../../common/logger';
Expand All @@ -8,13 +9,15 @@ import { IPipEnvServiceHelper } from './types';

const CheckPythonInterpreterRegEx = IS_WINDOWS ? /^python(\d+(.\d+)?)?\.exe$/ : /^python(\d+(.\d+)?)?$/;

export async function lookForInterpretersInDirectory(pathToCheck: string, fs: IFileSystem): Promise<string[]> {
export async function lookForInterpretersInDirectory(pathToCheck: string, _: IFileSystem): Promise<string[]> {
// Technically, we should be able to use fs.getFiles(). However,
// that breaks some tests. So we stick with the broader behavior.
try {
const subDirs = await fs.listdir(pathToCheck);
return subDirs
.map(([filename, _ft]) => filename)
// tslint:disable-next-line: no-suspicious-comment
// TODO https://github.com/microsoft/vscode-python/issues/11338
const files = await fsapi.readdir(pathToCheck);
return files
.map((filename) => path.join(pathToCheck, filename))
.filter((fileName) => CheckPythonInterpreterRegEx.test(path.basename(fileName)));
} catch (err) {
traceError('Python Extension (lookForInterpretersInDirectory.fs.listdir):', err);
Expand Down