Skip to content

Commit

Permalink
Fix #292: Check for Homebrew's OpenSSL libraries correctly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daviwil committed Dec 9, 2016
1 parent f596896 commit b231597
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
29 changes: 18 additions & 11 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ PowerShell extension for Visual Studio Code.

The most common problem when the PowerShell extension doesn't work on Mac OS X is that
OpenSSL is not installed. You can check for the installation of OpenSSL by looking for
the following two files:
the following files:

If installed using Homebrew:

```
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib
```

If installed by some other means:

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

#### Installing OpenSSL via Homebrew

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

```
brew install openssl
```

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):
First, install Homebrew and then run the following command:

```
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/libcrypto.1.0.0.dylib
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/libssl.1.0.0.dylib
brew install openssl
```

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

```
sudo ln -s /opt/local/lib/libcrypto.1.0.0.dylib /usr/local/lib/
sudo ln -s /opt/local/lib/libssl.1.0.0.dylib /usr/local/lib/
sudo ln -s /opt/local/lib/libcrypto.1.0.0.dylib /usr/local/lib/libcrypto.1.0.0.dylib
sudo ln -s /opt/local/lib/libssl.1.0.0.dylib /usr/local/lib/libssl.1.0.0.dylib
```

Thanks to [@MarlonRodriguez](https://github.com/MarlonRodriguez) for the tip!
Expand Down
9 changes: 6 additions & 3 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,12 @@ export class SessionManager {
else if (os.platform() == "darwin") {
powerShellExePath = "/usr/local/bin/powershell";

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

0 comments on commit b231597

Please sign in to comment.