我该如何修复未找到或版本不正确的心理模块 Ruby
How do I fix psych module not being found or being the right version Ruby
尝试使用 Ruby 执行任何操作时出现以下错误,特别是 ruby gems:
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:5:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `require': incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so (LoadError)
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:16:in `rescue in <top (required)>'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:13:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:6:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems.rb:729:in `load_yaml'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:349:in `load_file'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:202:in `initialize'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `new'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `do_configuration'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:44:in `run'
from /usr/local/rvm/rubies/ruby-2.4.5/bin/gem:21:in `<main>'
我相信注释行是这一行:
LoadError: incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so
我从 gem install puppet
、gem update
等那里得到这个。我尝试卸载并重新安装 libyaml,与 Ruby 相同。该错误发生在我执行 bundle uninstall puppet
以使其停止指向 6.3.0 gem 并指向 4.10.2 可执行文件之后。我需要 Ruby 才能使用 Rspec 来测试模块。有谁知道我该如何解决这个问题?
如果没有重现损坏系统的步骤,很难说出发生了什么,但我可以概括地说一下如何正确设置它以使用特定版本的 Puppet。
this有帮助吗?在最坏的情况下,您可能可以卸载 RVM 并重新安装它。
在我继续之前,请注意 Puppet 4.10.2 和 4.10.3 都是 removed 来自 Rubygems。 (虽然我能够使用 PDK 安装它。)
对于其余部分,我假定为 4.10.4(只是为了将其与最新的 4.10 区分开来)。
推荐的方法是使用 Puppet Development Kit (pdk)。如果您下载并安装 PDK,您可能只需要执行以下步骤:
pdk convert
rm Gemfile.lock
PUPPET_GEM_VERSION=4.10.4 bundle update # If that version isn't already in PDK.
pdk test unit --puppet-version 4.10.4
如果您不想走 PDK 之路,您可以尝试以下替代方案:
- 在 Gemfile 中硬编码您想要的 Puppet 版本。
gem 'puppet', '4.10.4'
或者:
gem 'puppet', '~> 4.10' # latest 4.10
然后更新您的包:
rm -f Gemfile.lock
bundle update
- 或者,您可以通过添加以下代码来实现
PUPPET_GEM_VERSION
功能(我就是这么做的,物有所值):
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion
else
gem 'puppet'
end
然后:
rm -f Gemfile.lock
PUPPET_GEM_VERSION='~> 4.10' bundle update
现在您可以运行您的单元测试针对特定版本的 Puppet 正常:
bundle exec rake spec
或者无论您如何设置。
尝试使用 Ruby 执行任何操作时出现以下错误,特别是 ruby gems:
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:5:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `require': incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so (LoadError)
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:16:in `rescue in <top (required)>'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:13:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:6:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems.rb:729:in `load_yaml'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:349:in `load_file'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:202:in `initialize'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `new'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `do_configuration'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:44:in `run'
from /usr/local/rvm/rubies/ruby-2.4.5/bin/gem:21:in `<main>'
我相信注释行是这一行:
LoadError: incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so
我从 gem install puppet
、gem update
等那里得到这个。我尝试卸载并重新安装 libyaml,与 Ruby 相同。该错误发生在我执行 bundle uninstall puppet
以使其停止指向 6.3.0 gem 并指向 4.10.2 可执行文件之后。我需要 Ruby 才能使用 Rspec 来测试模块。有谁知道我该如何解决这个问题?
如果没有重现损坏系统的步骤,很难说出发生了什么,但我可以概括地说一下如何正确设置它以使用特定版本的 Puppet。
this有帮助吗?在最坏的情况下,您可能可以卸载 RVM 并重新安装它。
在我继续之前,请注意 Puppet 4.10.2 和 4.10.3 都是 removed 来自 Rubygems。 (虽然我能够使用 PDK 安装它。)
对于其余部分,我假定为 4.10.4(只是为了将其与最新的 4.10 区分开来)。
推荐的方法是使用 Puppet Development Kit (pdk)。如果您下载并安装 PDK,您可能只需要执行以下步骤:
pdk convert
rm Gemfile.lock
PUPPET_GEM_VERSION=4.10.4 bundle update # If that version isn't already in PDK.
pdk test unit --puppet-version 4.10.4
如果您不想走 PDK 之路,您可以尝试以下替代方案:
- 在 Gemfile 中硬编码您想要的 Puppet 版本。
gem 'puppet', '4.10.4'
或者:
gem 'puppet', '~> 4.10' # latest 4.10
然后更新您的包:
rm -f Gemfile.lock
bundle update
- 或者,您可以通过添加以下代码来实现
PUPPET_GEM_VERSION
功能(我就是这么做的,物有所值):
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion
else
gem 'puppet'
end
然后:
rm -f Gemfile.lock
PUPPET_GEM_VERSION='~> 4.10' bundle update
现在您可以运行您的单元测试针对特定版本的 Puppet 正常:
bundle exec rake spec
或者无论您如何设置。