Skip to content

Commit 82ca03c

Browse files
elovelandaviwil
authored andcommitted
Remove macOS OpenSSL Error for PS Core Beta
.NET Core removed its dependency on OpenSSL on Mac in version 2.0. PowerShell Core Beta requires .NET Core 2.0 so it's safe to allow the PowerShell extension to launch if it detects the user is running PowerShell Core Beta
1 parent 44a02d1 commit 82ca03c

File tree

4 files changed

+39
-41
lines changed

4 files changed

+39
-41
lines changed

.travis.yml

-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ dist: trusty
1111
osx_image: xcode8.3
1212

1313
before_install:
14-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
15-
brew update;
16-
brew install openssl;
17-
mkdir -p /usr/local/lib;
18-
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/;
19-
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/;
20-
fi
2114
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
2215
nvm install v6.0.0;
2316
fi

build/download.sh

-26
Original file line numberDiff line numberDiff line change
@@ -113,34 +113,8 @@ case "$OSTYPE" in
113113
esac
114114
;;
115115
darwin*)
116-
patched=0
117-
if hash brew 2>/dev/null; then
118-
brew update
119-
if [[ ! -d $(brew --prefix openssl) ]]; then
120-
echo "Installing OpenSSL with brew..."
121-
if ! brew install openssl; then
122-
echo "ERROR: OpenSSL failed to install! Crypto functions will not work..." >&2
123-
# Don't abort because it is not fatal
124-
elif ! brew install curl --with-openssl; then
125-
echo "ERROR: curl failed to build against OpenSSL; SSL functions will not work..." >&2
126-
# Still not fatal
127-
else
128-
# OpenSSL installation succeeded; reme mber to patch System.Net.Http after PowerShell installation
129-
patched=1
130-
fi
131-
fi
132-
133-
else
134-
echo "ERROR: brew not found! OpenSSL may not be available..." >&2
135-
# Don't abort because it is not fatal
136-
fi
137-
138116
echo "Installing $package with sudo ..."
139117
sudo installer -pkg "./$package" -target /
140-
if [[ $patched -eq 1 ]]; then
141-
echo "Patching System.Net.Http for libcurl and OpenSSL..."
142-
find /usr/local/microsoft/powershell -name System.Net.Http.Native.dylib | xargs sudo install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib
143-
fi
144118
;;
145119
esac
146120

docs/troubleshooting.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ This issue has been resolved in PowerShell 5.1.
1919

2020
### 1. PowerShell IntelliSense does not work, can't debug scripts
2121

22-
The most common problem when the PowerShell extension doesn't work on macOS is that
23-
OpenSSL is not installed. You can check for the installation of OpenSSL by looking for
24-
the following files:
22+
The most common problem when the PowerShell extension doesn't work on macOS is that you have
23+
an alpha version of PowerShell installed. To upgrade to the latest beta, please follow the
24+
[Install Instructions](https://github.com/PowerShell/PowerShell/blob/master/docs/installation/linux.md#macos-1012).
25+
26+
If you'd prefer to use an alpha version of PowerShell, then OpenSSL must be installed.
27+
You can check for the installation of OpenSSL by looking for the following files:
2528

2629
If installed using Homebrew:
2730

src/session.ts

+33-5
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,18 @@ export class SessionManager implements Middleware {
105105

106106
this.createStatusBarItem();
107107

108-
// Check for OpenSSL dependency on macOS. Look for the default Homebrew installation
109-
// path and if that fails check the system-wide library path.
110-
if (os.platform() == "darwin") {
108+
this.powerShellExePath = this.getPowerShellExePath();
109+
110+
// Check for OpenSSL dependency on macOS when running PowerShell Core alpha. Look for the default
111+
// Homebrew installation path and if that fails check the system-wide library path.
112+
if (os.platform() == "darwin" && this.getPowerShellVersionLabel() == "alpha") {
111113
if (!(utils.checkIfFileExists("/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib") &&
112114
utils.checkIfFileExists("/usr/local/opt/openssl/lib/libssl.1.0.0.dylib")) &&
113115
!(utils.checkIfFileExists("/usr/local/lib/libcrypto.1.0.0.dylib") &&
114116
utils.checkIfFileExists("/usr/local/lib/libssl.1.0.0.dylib"))) {
115117
var thenable =
116118
vscode.window.showWarningMessage(
117-
"The PowerShell extension will not work without OpenSSL on macOS and OS X",
119+
"The PowerShell extension will not work without OpenSSL on macOS and OS X when using PowerShell alpha",
118120
"Show Documentation");
119121

120122
thenable.then(
@@ -131,7 +133,6 @@ export class SessionManager implements Middleware {
131133
}
132134

133135
this.suppressRestartPrompt = false;
134-
this.powerShellExePath = this.getPowerShellExePath();
135136

136137
if (this.powerShellExePath) {
137138

@@ -638,6 +639,33 @@ export class SessionManager implements Middleware {
638639
return resolvedPath;
639640
}
640641

642+
private getPowerShellVersionLabel(): string {
643+
if (this.powerShellExePath) {
644+
var powerShellCommandLine = [
645+
this.powerShellExePath,
646+
"-NoProfile",
647+
"-NonInteractive"
648+
];
649+
650+
// Only add ExecutionPolicy param on Windows
651+
if (utils.isWindowsOS()) {
652+
powerShellCommandLine.push("-ExecutionPolicy", "Bypass")
653+
}
654+
655+
powerShellCommandLine.push(
656+
"-Command",
657+
"'$PSVersionTable | ConvertTo-Json'");
658+
659+
var powerShellOutput = cp.execSync(powerShellCommandLine.join(' '));
660+
var versionDetails = JSON.parse(powerShellOutput.toString());
661+
return versionDetails.PSVersion.Label;
662+
}
663+
else {
664+
// TODO: throw instead?
665+
return null;
666+
}
667+
}
668+
641669
private showSessionConsole(isExecute?: boolean) {
642670
if (this.languageServerProcess) {
643671
this.languageServerProcess.showConsole(

0 commit comments

Comments
 (0)