如何安装 curl 开发依赖项 Ubuntu 20.04

如何安装 curl 开发依赖项 Ubuntu 20.04

尝试运行bundle install需要的 Ruby on Rails 项目gem curb。以下是发生的情况:

gem install curb
Fetching curb-0.9.11.gem
Building native extensions. This could take a while...
ERROR:  Error installing curb:
    ERROR: Failed to build gem native extension.

    current directory: /home/lance/.rvm/gems/ruby-2.6.4/gems/curb-0.9.11/ext
/usr/share/rvm/rubies/ruby-2.6.4/bin/ruby -I /usr/share/rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210120-31208-z4fk7m.rb extconf.rb
checking for curl-config... no
checking for -lcurl... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/share/rvm/rubies/ruby-2.6.4/bin/$(RUBY_BASE_NAME)
    --with-curl-dir
    --without-curl-dir
    --with-curl-include
    --without-curl-include=${curl-dir}/include
    --with-curl-lib
    --without-curl-lib=${curl-dir}/lib
    --with-curllib
    --without-curllib
extconf.rb:18:in `<main>':   Can't find libcurl or curl/curl.h (RuntimeError)

  Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
  options to extconf.

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/lance/.rvm/gems/ruby-2.6.4/extensions/x86_64-linux/2.6.0/curb-0.9.11/mkmf.log

extconf failed, exit code 1

答案1

需要安装正确的软件包。错误显示问题,curl.h因此请转到http://packages.ubuntu.com并搜索curl.h显示需要安装的内容:

sudo apt-get install libcurl4-gnutls-dev libcurl4-nss-dev libcurl4-openssl-dev

相关内容