0

我有一个在 linux 服务器上运行的旧版 ruby​​ 守护程序脚本。在使用实例中升级所有 ruby​​ 和 gem 包版本时,守护程序脚本现在出错了。我在 irb 中遇到的同样错误

**

/home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core/xml/parser.rb:74:in `set_default_engine': Unable to find a compatible xml library. Ensure that you have installed or added to your Gemfile one of ox, oga, libxml, nokogiri or rexml (RuntimeError)
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core/xml/parser.rb:96:in `<class:Parser>'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core/xml/parser.rb:7:in `<module:Xml>'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core/xml/parser.rb:5:in `<module:Aws>'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core/xml/parser.rb:3:in `<top (required)>'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core/xml.rb:8:in `require_relative'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core/xml.rb:8:in `<top (required)>'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core.rb:68:in `require_relative'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-core-3.121.0/lib/aws-sdk-core.rb:68:in `<top (required)>'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-kms-1.48.0/lib/aws-sdk-kms.rb:11:in `<top (required)>'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from /home/ec2-user/.local/share/gem/ruby/gems/aws-sdk-s3-1.102.0/lib/aws-sdk-s3.rb:11:in `<top (required)>'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:160:in `require'
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
    ... 5 levels...
<internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- aws-sdk-s3 (LoadError)
    from <internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from (irb):1:in `<main>'
    from /usr/share/gems/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
    from /usr/bin/irb:23:in `load'
    from /usr/bin/irb:23:in `<main>'

**

aws-sdk-core 版本:3.121.0

宝石列表的输出

**

*** LOCAL GEMS ***
abbrev (default: 0.1.0)
aws-eventstream (1.2.0)
aws-partitions (1.501.0)
aws-sdk-core (3.121.0)
aws-sdk-kms (1.48.0)
aws-sdk-s3 (1.102.0)
aws-sdk-sqs (1.44.0)
aws-sigv4 (1.4.0)
base64 (default: 0.1.0)
benchmark (default: 0.1.1)
bigdecimal (3.0.0)
bundler (2.2.22)
cgi (default: 0.2.0)
csv (default: 3.1.9)
daemons (1.4.1)
date (default: 3.1.0)
dbm (default: 1.1.0)
debug (default: 0.1.0)
delegate (default: 0.2.0)
did_you_mean (default: 1.5.0)
digest (default: 3.0.0)
drb (default: 2.0.4)
english (default: 0.7.1)
erb (default: 2.2.0)
etc (default: 1.2.0)
fcntl (default: 1.0.0)
fiddle (default: 1.0.6)
fileutils (default: 1.5.0)
find (default: 0.1.0)
forwardable (default: 1.3.2)
gdbm (default: 2.1.0)
getoptlong (default: 0.1.1)
io-console (0.5.7)
io-nonblock (default: 0.1.0)
io-wait (default: 0.1.0)
ipaddr (default: 1.2.2)
irb (1.3.5)
jmespath (1.4.0)
json (2.5.1)
logger (default: 1.4.3)
matrix (default: 0.3.1)
mutex_m (default: 0.1.1)
net-ftp (default: 0.1.2)
net-http (default: 0.1.1)
net-imap (default: 0.1.1)
net-pop (default: 0.1.1)
net-protocol (default: 0.1.0)
net-smtp (default: 0.2.1)
nkf (default: 0.1.0)
observer (default: 0.1.1)
open-uri (default: 0.1.0)
open3 (default: 0.1.1)
openssl (default: 2.2.0)
optparse (default: 0.1.0)
ostruct (default: 0.3.1)
pathname (default: 0.1.0)
pp (default: 0.1.0)
prettyprint (default: 0.1.0)
prime (default: 0.1.2)
pstore (default: 0.1.1)
psych (3.3.0)
racc (default: 1.5.1)
rake (13.0.3)
rdoc (6.3.1)
readline (default: 0.0.2)
readline-ext (default: 0.1.1)
reline (default: 0.2.5)
resolv (default: 0.2.0)
resolv-replace (default: 0.1.0)
rinda (default: 0.1.0)
rubysl-securerandom (2.0.0)
securerandom (default: 0.1.0)
set (default: 1.0.1)
shellwords (default: 0.1.0)
singleton (default: 0.1.1)
stringio (default: 3.0.0)
strscan (default: 3.0.0)
syslog (default: 0.1.0)
tempfile (default: 0.1.1)
time (default: 0.1.0)
timeout (default: 0.1.1)
tmpdir (default: 0.1.2)
tracer (default: 0.1.1)
tsort (default: 0.1.0)
un (default: 0.1.0)
uri (default: 0.10.1)
weakref (default: 0.1.1)
yaml (default: 0.1.1)
zlib (default: 1.1.0)

**

宝石环境的输出

**

RubyGems Environment:
  - RUBYGEMS VERSION: 3.2.22
  - RUBY VERSION: 3.0.2 (2021-07-07 patchlevel 107) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/share/gems
  - USER INSTALLATION DIRECTORY: /home/ec2-user/.local/share/gem/ruby
  - RUBY EXECUTABLE: /usr/bin/ruby
  - GIT EXECUTABLE: 
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /home/ec2-user/.local/share/gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-linux
  - GEM PATHS:
     - /usr/share/gems
     - /home/ec2-user/.local/share/gem/ruby
     - /usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--user-install --bindir /home/ec2-user/bin"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/bin
     - /usr/local/sbin
     - /usr/sbin
     - /home/ec2-user/.local/bin
     - /home/ec2-user/bin

**

任何帮助将不胜感激。

4

2 回答 2

1

就我而言,我刚刚做了gem install nokogiri,它在这里工作。

也许您的守护程序脚本获得的上下文/环境与在本地运行不同,尽管我很惊讶 irb 在这种情况下给出了同样的问题。

于 2021-10-06T14:59:09.513 回答
0

安装几个依赖包后问题得到解决

yum -y install gcc mysql-devel ruby-devel rubygems

然后安装nokogiri工作正常

于 2021-10-08T18:44:58.093 回答