在 Ubuntu 20.04 上安装 fpm

在 Ubuntu 20.04 上安装 fpm

ruby2.3我尝试在 Ubuntu 20.04 上安装。sudo apt install ruby2.3由于无法找到软件包而失败ruby2.3。然后我尝试通过以下方式安装snap

$ sudo snap install ruby --classic
$ sudo snap switch ruby --channel=2.3/stable
$ sudo snap refresh

然后我尝试安装fpm

$ gem install fpm
Fetching: stud-0.0.23.gem (100%)
Successfully installed stud-0.0.23
Fetching: cabin-0.9.0.gem (100%)
Successfully installed cabin-0.9.0
Fetching: clamp-1.0.1.gem (100%)
Successfully installed clamp-1.0.1
Fetching: mustache-0.99.8.gem (100%)
Successfully installed mustache-0.99.8
Fetching: insist-1.0.0.gem (100%)
Successfully installed insist-1.0.0
Fetching: dotenv-2.7.6.gem (100%)
Successfully installed dotenv-2.7.6
Fetching: pleaserun-0.0.31.gem (100%)
Successfully installed pleaserun-0.0.31
Fetching: io-like-0.3.1.gem (100%)
Successfully installed io-like-0.3.1
Fetching: ffi-1.13.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing fpm:
    ERROR: Failed to build gem native extension.

    current directory: /home/t/.gem/gems/ffi-1.13.1/ext/ffi_c
/snap/bin/ruby -r ./siteconf20200928-71416-wr10i1.rb extconf.rb
mkmf.rb can't find header files for ruby at /snap/ruby/109/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /home/t/.gem/gems/ffi-1.13.1 for inspection.
Results logged to /home/t/.gem/extensions/x86_64-linux/2.3.0-static/ffi-1.13.1/gem_make.out

其他解决方案似乎建议安装ruby-dev,但ruby2.3-dev不可用,也不可用ruby2.3.8-dev

答案1

使用命令

sudo apt-get install ruby-dev build-essential && sudo gem i fpm -f

不要通过 snap 安装 ruby​​。在我的例子中,它有效:

fpm --version
1.12.0

有关 ubuntu 上的 fpm 的完整文章:

https://www.digitalocean.com/community/tutorials/how-to-use-fpm-to-easily-create-packages-in-multiple-formats

相关内容