Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-WebRequest throws an error on OS X El Capitan #1919

Closed
AdilHindistan opened this issue Aug 19, 2016 · 18 comments
Closed

Invoke-WebRequest throws an error on OS X El Capitan #1919

AdilHindistan opened this issue Aug 19, 2016 · 18 comments
Assignees
Labels
Issue-Bug Issue has been identified as a bug in the product OS-macOS WG-Cmdlets general cmdlet issues

Comments

@AdilHindistan
Copy link

Steps to reproduce

Invoke-WebRequest -Uri "www.microsoft.com"

Expected behavior

Should return an object holding web request results

Actual behavior

Returns an error:
invoke-webrequest : The type initializer for 'System.Net.Http.CurlHandler' threw an exception.
At line:1 char:1

  • invoke-webrequest "www.microsoft.com"
  • - CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], TypeInitializationException
    - FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

Environment data

Name Value


PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.9
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion

screen shot 2016-08-18 at 8 07 23 pm

1.1.0.1
@lzybkr lzybkr added Issue-Bug Issue has been identified as a bug in the product OS-macOS WG-Cmdlets general cmdlet issues labels Aug 19, 2016
@ffeldhaus
Copy link
Contributor

The command works for me on Mac OS X 10.11.6 with the same PowerShell version you have.

@qlikq
Copy link

qlikq commented Aug 19, 2016

I have exactly same issue
Mac OSX 10.11.4
PS /Users/gregu/Desktop> Invoke-RestMethod -uri google.com
Invoke-RestMethod : The type initializer for 'System.Net.Http.CurlHandler' threw an exception.
At line:1 char:1

  • Invoke-RestMethod -uri google.com
  • - CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], TypeInitializationException
    - FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
    

@gavinelder
Copy link

I was able to reproduce and resolve this issue by installing .net core https://www.microsoft.com/net/core#macos

Powershell needs .net core to function fully.

@qlikq
Copy link

qlikq commented Aug 19, 2016

setsquared: bingo ! thank you for helping out ! Works as expected now.

@daxian-dbw
Copy link
Member

@andschwa is the powershell package for os x having the pre-requisites installed?

@andyleejordan
Copy link
Member

There's no way to install prereqs with a PKG. We should dump it for a homebrew formula ASAP.

I do believe the installation documentation is missing OpenSSL info; although the manual link step should be unnecessary as we patch the .NET Core binaries.

Someone recently pointed out that Http.Client may require curl to be installed --with-openssl.

@andyleejordan
Copy link
Member

@gavinelder PowerShell does not need .NET Core installed; PowerShell ships its own copy of .NET Core.

Unfortunately, .NET Core really broke their OpenSSL support, and now require the extra manual setup:

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

But this should never be done on a system, for the very good reasons that the homebrew team stopped allowing you to brew link --force openssl.

Instead, we patch the provided .NET Core crypto libraries to look for OpenSSL in the right place, provided it's been installed. (Documentation here needs to be updated.)

@closedstack
Copy link

still getting the error with latest download on Oct 14

PS /Users/sunilm> $PSVersionTable

Name Value


PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.10
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

OpenSSL 0.9.8zh 14 Jan 2016

@andyleejordan
Copy link
Member

@vors did you patch your binaries when you built the last OS X package?

@andyleejordan
Copy link
Member

@closedstack build from source, it's fixed but requires all the different .NET Core crypto libraries to be patched (like those in ~/.nuget). My guess is the packager didn't clear those out after Start-PSBootstrap was fixed to patch them. Let me know if it repros after building completely cleanly from source.

@closedstack
Copy link

@andschwa Didn't build it. Downloaded the latest binary for OS X from github. Maybe that binary needs to be rebuilt?

@andyleejordan
Copy link
Member

@closedstack I know, I'm suggesting you build from source until the package is rebuilt.

@vors
Copy link
Collaborator

vors commented Oct 18, 2016

@andschwa I wiped out ~/.nuget for the upcoming release alpha.11.

@andyleejordan
Copy link
Member

Confirmed: the fix was picked up in alpha.11. 🎉

@closedstack
Copy link

Installed Aplha 11 on top of Alpha 10, still getting the same error I think. I wish the errors were more descriptive

Invoke-WebRequest -Uri www.bing.com
Invoke-WebRequest : The type initializer for 'System.Net.Http.CurlHandler' threw an exception.
At line:1 char:1

  • Invoke-WebRequest -Uri www.bing.com
  • - CategoryInfo          : NotSpecified: (:) [Invoke-WebRequest], TypeInitializationException
    - FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    

@andyleejordan
Copy link
Member

Okay I have to ask: did you install OpenSSL through home brew?

@closedstack
Copy link

no.. in fact I didn't even have homebrew installed until yesterday and no openssl through homebrew.
OpenSSL 0.9.8zh 14 Jan 2016

@andyleejordan
Copy link
Member

Okay, install OpenSSL per the OS X installation docs. .NET Core requires
this.

On Tue, Oct 18, 2016, 5:30 PM closedstack notifications@github.com wrote:

no.. in fact I didn't even have homebrew installed until yesterday and no
openssl through homebrew.

OpenSSL 0.9.8zh 14 Jan 2016

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1919 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACH5Akj987l2RaI-klvgunDxzgw0Ki4yks5q1WS_gaJpZM4JoCJy
.

-- Andy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Issue has been identified as a bug in the product OS-macOS WG-Cmdlets general cmdlet issues
Projects
None yet
Development

No branches or pull requests

9 participants