Skip to content

Commit b231597

Browse files
committed
Fix #292: Check for Homebrew's OpenSSL libraries correctly
This change improves the way we check for OpenSSL libraries that must be installed on the user's macOS system before PowerShell Editor Services can be loaded successfully. Previously we were looking for a path that required a symbolic link to be created after installing OpenSSL. It turns out that PowerShell on macOS has built-in library paths which target Homebrew's installation path for OpenSSL. We now check primarily for this path before looking at the system-wide installation path.
1 parent f596896 commit b231597

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

docs/troubleshooting.md

+18-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ PowerShell extension for Visual Studio Code.
99

1010
The most common problem when the PowerShell extension doesn't work on Mac OS X is that
1111
OpenSSL is not installed. You can check for the installation of OpenSSL by looking for
12-
the following two files:
12+
the following files:
13+
14+
If installed using Homebrew:
15+
16+
```
17+
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
18+
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib
19+
```
20+
21+
If installed by some other means:
1322

1423
```
1524
/usr/local/lib/libcrypto.1.0.0.dylib
@@ -21,17 +30,15 @@ do not have OpenSSL installed.
2130

2231
#### Installing OpenSSL via Homebrew
2332

24-
You can use [Homebrew](http://brew.sh) to easily install OpenSSL. First, install Homebrew and then run the following command:
33+
We **highly recommend** that you use [Homebrew](http://brew.sh) to install OpenSSL. The PowerShell distribution for OS X
34+
has built-in support for Homebrew's OpenSSL library paths. If you install with Homebrew, you will avoid
35+
[security concerns](https://github.com/PowerShell/PowerShell/blob/master/docs/installation/linux.md#openssl)
36+
around creating symbolic links in your `/usr/local/lib` path which are needed when using other means of installation.
2537

26-
```
27-
brew install openssl
28-
```
29-
30-
After installation, the libraries of interest must be symlinked to `/usr/local/lib`; e.g. (note that /usr/local/lib may not already exist and may need to be created before symlinking):
38+
First, install Homebrew and then run the following command:
3139

3240
```
33-
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/libcrypto.1.0.0.dylib
34-
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/libssl.1.0.0.dylib
41+
brew install openssl
3542
```
3643

3744
Restart VS Code after completing the installation and verify that the extension is working correctly.
@@ -47,8 +54,8 @@ sudo port install openssl
4754
You will need to take an additional step once installation completes:
4855

4956
```
50-
sudo ln -s /opt/local/lib/libcrypto.1.0.0.dylib /usr/local/lib/
51-
sudo ln -s /opt/local/lib/libssl.1.0.0.dylib /usr/local/lib/
57+
sudo ln -s /opt/local/lib/libcrypto.1.0.0.dylib /usr/local/lib/libcrypto.1.0.0.dylib
58+
sudo ln -s /opt/local/lib/libssl.1.0.0.dylib /usr/local/lib/libssl.1.0.0.dylib
5259
```
5360

5461
Thanks to [@MarlonRodriguez](https://github.com/MarlonRodriguez) for the tip!

src/session.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,12 @@ export class SessionManager {
454454
else if (os.platform() == "darwin") {
455455
powerShellExePath = "/usr/local/bin/powershell";
456456

457-
// Check for OpenSSL dependency on OS X
458-
if (!utils.checkIfFileExists("/usr/local/lib/libcrypto.1.0.0.dylib") ||
459-
!utils.checkIfFileExists("/usr/local/lib/libssl.1.0.0.dylib")) {
457+
// Check for OpenSSL dependency on OS X. Look for the default Homebrew installation
458+
// path and if that fails check the system-wide library path.
459+
if (!(utils.checkIfFileExists("/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib") &&
460+
utils.checkIfFileExists("/usr/local/opt/openssl/lib/libssl.1.0.0.dylib")) &&
461+
!(utils.checkIfFileExists("/usr/local/lib/libcrypto.1.0.0.dylib") &&
462+
utils.checkIfFileExists("/usr/local/lib/libssl.1.0.0.dylib"))) {
460463
var thenable =
461464
vscode.window.showWarningMessage(
462465
"The PowerShell extension will not work without OpenSSL on Mac OS X",

0 commit comments

Comments
 (0)