Skip to content

Commit 2555122

Browse files
authored
Merge pull request #2011 from zooba/issue-2010
Fixes #2010 Interpreter link crashes when path variable not set
2 parents b4d4d0c + f7b9ecd commit 2555122

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Python/Product/PythonTools/PythonTools/InterpreterList/InterpreterListToolWindow.cs

+12-10
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,18 @@ private void StartInterpreter_Executed(object sender, ExecutedRoutedEventArgs e)
284284
factory.Configuration.WindowsInterpreterPath;
285285
psi.WorkingDirectory = factory.Configuration.PrefixPath;
286286

287-
var provider = _service.KnownProviders.OfType<LoadedProjectInterpreterFactoryProvider>().FirstOrDefault();
288-
var vsProject = provider == null ?
289-
null :
290-
provider.GetProject(factory);
291-
var project = vsProject == null ? null : vsProject.GetPythonProject();
292-
if (project != null) {
293-
psi.EnvironmentVariables[factory.Configuration.PathEnvironmentVariable] =
294-
string.Join(";", project.GetSearchPaths());
295-
} else {
296-
psi.EnvironmentVariables[factory.Configuration.PathEnvironmentVariable] = string.Empty;
287+
var pathVar = factory.Configuration.PathEnvironmentVariable;
288+
if (!string.IsNullOrEmpty(pathVar)) {
289+
var provider = _service.KnownProviders.OfType<LoadedProjectInterpreterFactoryProvider>().FirstOrDefault();
290+
var vsProject = provider == null ?
291+
null :
292+
provider.GetProject(factory);
293+
var project = vsProject == null ? null : vsProject.GetPythonProject();
294+
if (project != null) {
295+
psi.EnvironmentVariables[pathVar] = string.Join(";", project.GetSearchPaths());
296+
} else {
297+
psi.EnvironmentVariables[pathVar] = string.Empty;
298+
}
297299
}
298300

299301
Process.Start(psi);

0 commit comments

Comments
 (0)