backports-3.24.1/lib/backports/ractor/cloner.rb:36:in ‘private‘: nil is not a symbol(TypeError)的解决方案

文章目录

  • 1、问题描述
  • 2、原因分析
  • 3、解决方案
  • 4、总结


1、问题描述

在使用gem命令:

gem install fpm

安装fpm包后,执行:

fpm -help

出现以下报错信息:

[root@localhost ~]# fpm -help
/usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/cloner.rb:36:in `private': nil is not a symbol (TypeError)
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/cloner.rb:36:in `'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/cloner.rb:7:in `'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/cloner.rb:6:in `'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/cloner.rb:5:in `'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/ractor.rb:9:in `require_relative'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/ractor.rb:9:in `'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/ractor.rb:6:in `'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/ractor/ractor.rb:5:in `'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/3.0.0/ractor.rb:18:in `require_relative'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/3.0.0/ractor.rb:18:in `'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/tools/require_relative_dir.rb:12:in `require_relative'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/tools/require_relative_dir.rb:12:in `block in require_relative_dir'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/tools/require_relative_dir.rb:9:in `each'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/tools/require_relative_dir.rb:9:in `require_relative_dir'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/3.0.0.rb:3:in `'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/3.1.0.rb:2:in `'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/gems/gems/backports-3.24.1/lib/backports/latest.rb:4:in `'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:126:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:126:in `require'
        from /usr/local/share/gems/gems/fpm-1.15.1/lib/fpm/package.rb:7:in `'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:73:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:73:in `require'
        from /usr/local/share/gems/gems/fpm-1.15.1/lib/fpm.rb:3:in `'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:73:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:73:in `require'
        from /usr/local/share/gems/gems/fpm-1.15.1/bin/fpm:4:in `'
        from /usr/local/bin/fpm:23:in `load'
        from /usr/local/bin/fpm:23:in `
'

2、原因分析

通过查看报错日志,发现是backports-3.24.1在报错,个人感觉是版本冲突问题导致的,所以考虑换一个低版本的backports。


3、解决方案

首先,卸载当前安装的backports-3.24.1包:

gem uninstall backports

先尝试更换 backports-3.8.0 这个版本:

gem install backports -v 3.8.0

并再次执行fpm -help

[root@localhost ~]# gem install backports -v 3.8.0
Successfully installed backports-3.8.0
Parsing documentation for backports-3.8.0
1 gem installed
[root@localhost ~]# fpm -help
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- backports/latest (LoadError)
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/gems/gems/fpm-1.15.1/lib/fpm/package.rb:7:in `'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/gems/gems/fpm-1.15.1/lib/fpm.rb:3:in `'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/local/share/gems/gems/fpm-1.15.1/bin/fpm:4:in `'
        from /usr/local/bin/fpm:23:in `load'
        from /usr/local/bin/fpm:23:in `
'

报错backports/latest,提示版本过低了。再换一个折中的版本3.20.1:

gem install backports -v 3.20.1
[root@localhost ~]# gem install backports -v 3.20.1
Fetching: backports-3.20.1.gem (100%)
Successfully installed backports-3.20.1
Parsing documentation for backports-3.20.1
Installing ri documentation for backports-3.20.1
1 gem installed

再执行fpm -help,终于fpm安装成功!
backports-3.24.1/lib/backports/ractor/cloner.rb:36:in ‘private‘: nil is not a symbol(TypeError)的解决方案_第1张图片


4、总结

fpm和backports出现版本冲突,更换适合的版本即可。

你可能感兴趣的:(Linux,linux,服务器,gem)