Skip to content

Commit e2b65bc

Browse files
committed
add support for more paths on OSX
1 parent f21a928 commit e2b65bc

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎src/client/providers/setInterpreterProvider.ts‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ function getSearchPaths(): Promise<string[]> {
2626
const localAppData = process.env['LOCALAPPDATA'];
2727
const appData = process.env['APPDATA'];
2828
const lookupParentDirectories = [process.env['PROGRAMFILES'], process.env['PROGRAMFILES(X86)'],
29-
localAppData, appData,
30-
process.env['SystemDrive']];
31-
if (appData){
29+
localAppData, appData,
30+
process.env['SystemDrive']];
31+
if (appData) {
3232
lookupParentDirectories.push(path.join(localAppData, 'Programs'))
3333
}
34-
if (localAppData){
34+
if (localAppData) {
3535
lookupParentDirectories.push(path.join(appData, 'Programs'))
3636
}
3737
const dirPromises = lookupParentDirectories.map(rootDir => {
@@ -47,7 +47,7 @@ function getSearchPaths(): Promise<string[]> {
4747
files.forEach(name => {
4848
const fullPath = path.join(rootDir, name);
4949
try {
50-
if ((name.toUpperCase().indexOf('PYTHON') >= 0 || name.toUpperCase().indexOf('ANACONDA') >= 0) &&
50+
if ((name.toUpperCase().indexOf('PYTHON') >= 0 || name.toUpperCase().indexOf('ANACONDA') >= 0) &&
5151
fs.statSync(fullPath).isDirectory()) {
5252
possiblePythonDirs.push(fullPath);
5353
}
@@ -64,7 +64,13 @@ function getSearchPaths(): Promise<string[]> {
6464
return validPathsCollection.reduce((previousValue, currentValue) => previousValue.concat(currentValue), []);
6565
});
6666
} else {
67-
return Promise.resolve(['/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin']);
67+
const paths = ['/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/sbin'];
68+
// Add support for paths such as /Users/xxx/anaconda/bin
69+
if (process.env['HOME']) {
70+
paths.push(path.join(process.env['HOME'], 'anaconda', 'bin'));
71+
paths.push(path.join(process.env['HOME'], 'python', 'bin'));
72+
}
73+
return Promise.resolve(paths);
6874
}
6975
}
7076

0 commit comments

Comments
 (0)