尝试使用Ruby(特别是红宝石)做任何事情时,出现以下错误:
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"code",
"message",
"payload"
})
public class Train {
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property = "@type")
@JsonProperty("code")
private String code;
@JsonProperty("message")
private String message;
@JsonProperty("payload")
private List<Payload> payload = null;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
//Getter
//Setter
我相信注意的是这一行:
/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
等那里获得的。我尝试卸载并重新安装libyaml,并且与Ruby相同。在执行gem update
使其停止指向6.3.0 gem并指向4.10.2可执行文件之后,发生了错误。我需要Ruby才能使用Rspec来测试模块。有谁知道我该如何解决?
答案 0 :(得分:1)
没有步骤来重现损坏的系统,很难说出发生了什么,但是我可以说一般地说,如何正确设置它以使用特定版本的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路径,可以尝试以下替代方法:
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
或者您进行设置。