Skip to content

Commit 825513a

Browse files
committed
Fix #264: Check for OpenSSL on OS X before starting Editor Services
This change adds a check when the extension initializes to verify whether the machine has OpenSSL installed when running on OS X. This is currently a requirement of PowerShell which must be met before PowerShell Editor Services can be started. If the proper library paths are not detected, a message is shown to the user which leads them to documentation on how to install OpenSSL.
1 parent 9f0c8e5 commit 825513a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/main.ts

+20
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,26 @@ export function activate(context: vscode.ExtensionContext): void {
112112
}
113113
else if (os.platform() == "darwin") {
114114
powerShellExePath = "/usr/local/bin/powershell";
115+
116+
// Check for OpenSSL dependency on OS X
117+
if (!utils.checkIfFileExists("/usr/local/lib/libcrypto.1.0.0.dylib") ||
118+
!utils.checkIfFileExists("/usr/local/lib/libssl.1.0.0.dylib")) {
119+
var thenable =
120+
vscode.window.showWarningMessage(
121+
"The PowerShell extension will not work without OpenSSL on Mac OS X",
122+
"Show Documentation");
123+
124+
thenable.then(
125+
(s) => {
126+
if (s === "Show Documentation") {
127+
cp.exec("open https://github.com/PowerShell/vscode-powershell/blob/master/docs/troubleshooting.md#1-powershell-intellisense-does-not-work-cant-debug-scripts");
128+
}
129+
});
130+
131+
// Don't continue initializing since Editor Services will not load successfully
132+
console.log("Cannot start PowerShell Editor Services due to missing OpenSSL dependency.");
133+
return;
134+
}
115135
}
116136
else {
117137
powerShellExePath = "/usr/bin/powershell";

src/utils.ts

+10
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,14 @@ export function readSessionFile(): EditorServicesSessionDetails {
7979

8080
export function deleteSessionFile() {
8181
fs.unlinkSync(sessionFilePath);
82+
}
83+
84+
export function checkIfFileExists(filePath: string): boolean {
85+
try {
86+
fs.accessSync(filePath, fs.R_OK)
87+
return true;
88+
}
89+
catch (e) {
90+
return false;
91+
}
8292
}

0 commit comments

Comments
 (0)