curl: (48) An unknown option was passed in to libc

2019-01-26 04:33发布

问题:

This is really frustrating. I keep getting this error when trying to run a standard curl command:

curl --url https://install.meteor.com | sh
curl: (48) An unknown option was passed in to libcurl

Anyone know how to fix it?

回答1:

I've just run into this problem myself. A bit of cursory research led me to this bug tracker entry, but updating didn't do the trick. I recently built the newest version of libcurl from source, though, so I figured it must be something to do with the directory structure getting mixed up. I'm sure you're probably not in the exact same situation, but perhaps Mountain Lion introduced a similar enough error that the steps I took to fix the problem might be able to help.

First, run which curl to determine where the binary is being called from. Then make sure that location actually exists by running locate -r /curl$. If it doesn't (this was the issue in my case), try running curl using all of the full paths provided by locate, ignoring the obviously superfluous ones like python-pycurl.

Once you've found one that works, you can either create a symlink to it from the one which found, or else check to see whether removing the latter will allow the shell to find the correct one on its own. For me, the fix was as simple as removing /usr/local/bin/curl, causing which curl to correctly respond with /usr/bin/curl and curl itself to return to normal operation.



回答2:

Just had this exact issue with Alpine Linux.

The fix was to install curl-dev in addition to curl.



回答3:

Most likely you have a newer curl that uses an older libcurl that doesn't know of one or more options curl tries to use.

curl -V will show this and ldd [path to curl] will show you all shared libraries curl uses.



回答4:

This is the same error I was getting after installing cURL from source on Ubuntu.

$ curl http://www.google.com
curl: (48) An unknown option was passed in to libcurl

Looking at cURL's version showed that curl had updated but was using the old version of libcurl:

$ curl --version
curl 7.41.0 (x86_64-unknown-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3

To resolve my issue I copied libcurl.so and others from the latest curl folder which I downloaded and overwrote the ones already on my machine.

cp /tmp/curl-7.41.0/lib/.libs/libcurl.so* /usr/local/lib/

This fixed my issue.

$ curl --version
curl 7.41.0 (x86_64-unknown-linux-gnu) libcurl/7.41.0 OpenSSL/1.0.1 zlib/1.2.3.4

$ curl -I http://www.google.com
HTTP/1.1 302 Found
[...snip...]


回答5:

If you just built your curl from source, run sudo ldconfig to fix it.



回答6:

This can be fixed by reinstalling cURL into /usr/bin instead of /usr/local/bin as Ubuntu 12.04 behaves weird when you install in different places

Also, this can be a possible fix, but be careful

ln -s /usr/bin/curl /usr/local/bin/curl

This means, the binary in /usr/local/bin isn't really the one the system is looking for or is outdated or cannot function properly. A simple symbolic link is required.


To be safe you might as well

mv /usr/local/bin/curl /usr/local/bin/curl.bak

before ln -s-ing the /usr/bin/curl version over.



回答7:

I had a similar problem (in Ubuntu 12.04). I manually installed curl in usr/local/bin and any command I type was giving curl:(48) An unknown option was passed in to libcurl

I fixed it uninstalling curl (sudo make uninstall) and installing it from apt-get (sudo apt-get install curl), which automatically placed curl in usr/bin. Then it worked!



回答8:

I also got this error, but I'm not running Mountain Lion, and I wanted a simple, clean way to get it right for sure - on any system. (Note #1: I happen to be in a crouton Ubuntu/LXDE chroot on an old ARMv7 Chromebook.) (Note #2: I built the nightly release from source. I had no issue with installing curl the traditional way, i.e. sudo apt-get install curl.)

When I checked the version curl -V it showed my brand new nightly build version for curl: 7.51.1-20161107, but an old libcurl: 7.22...

I had a hunch this was the problem. I tried messing around with symbolic links, but it didn't work for me and I was only making a mess, so I consulted the official install page: https://curl.haxx.se/docs/install.html.

To force a static library compile, disable the shared library creation by running configure like:

./configure --disable-shared

So I ran the following from my curl source directory:

  1. sudo make uninstall
  2. ./configure --disable-shared
  3. make
  4. sudo make install

Now the curl version matches the libcurl version, and it works.



回答9:

On Ubuntu 16.04 LTS I just added /usr/local/lib to the LD_LIBRARY_PATH in /etc/profile (LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH)



回答10:

I faced the same issue on cygwin, when I manually built curl to work with https and everything was working fine

until one day I updated the curl package by running cygwin setup and didn't update the package libcurl4, and started getting the same error.

I checked curl version information by running:

$ curl -V
curl 7.54.1 (i686-pc-cygwin) libcurl/7.52.1 OpenSSL/1.0.2j zlib/1.2.8 libidn2/2.0.2 libpsl/0.17.0 (+libidn2/0.11) libssh2/1.7.0 nghttp2/1.14.0
Release-Date: 2017-06-14
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: Debug IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy Metalink PSL

So I found that cygwin updated the package curl to 7.54.1 but libcurl was still at 7.52.1

So I uninstalled the package curl and libcurl and reinstalled then everything was running fine again.

$ apt-cyg remove libcurl4 curl
Removing libcurl4
Package libcurl4 removed
Removing curl
Package curl removed

apt-cyg install curl libcurl4
Installing curl
curl-7.54.1-1.tar.xz: OK
Unpacking...
Package curl requires the following packages, installing:
cygwin libcurl4 libmetalink3 libopenssl100 zlib0
Package cygwin is already installed, skipping
Installing libcurl4
libcurl4-7.54.1-1.tar.xz: OK
Unpacking...
Package libcurl4 requires the following packages, installing:
ca-certificates cygwin libgcc1 libgssapi_krb5_2 libidn2_0 libnghttp2_14 libopenldap2_4_2 libopenssl100 libpsl5 libssh2_1 zlib0
Package ca-certificates is already installed, skipping
Package cygwin is already installed, skipping
Package libgcc1 is already installed, skipping
Package libgssapi_krb5_2 is already installed, skipping
Package libidn2_0 is already installed, skipping
Package libnghttp2_14 is already installed, skipping
Package libopenldap2_4_2 is already installed, skipping
Package libopenssl100 is already installed, skipping
Package libpsl5 is already installed, skipping
Package libssh2_1 is already installed, skipping
Package zlib0 is already installed, skipping
Package libmetalink3 is already installed, skipping
Package libopenssl100 is already installed, skipping
Package zlib0 is already installed, skipping
Package curl installed
Package libcurl4 is already installed, skipping

Checked curl version information again:

$ curl -V
curl 7.54.1 (i686-pc-cygwin) libcurl/7.54.1 OpenSSL/1.0.2j zlib/1.2.8 libidn2/2.0.2 libpsl/0.17.0 (+libidn2/0.11) libssh2/1.7.0 nghttp2/1.14.0
Release-Date: 2017-06-14
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS Debug IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy Metalink PSL


回答11:

Got into the same problem after having compiled from source over a packaged installation, solved it with the correct flags with configure :

./configure --prefix=/usr --libdir=/usr/lib64

Without the --libdir= option, mine was installing an updated version of libcurl into /usr/lib instead of /usr/lib64 and the new curl binary was still accessing the old libraries, leading to incompatibility.



回答12:

Drop the --url parameter:

curl https://install.meteor.com | /bin/sh