代码之家  ›  专栏  ›  技术社区  ›  aphexlog

Ruby在尝试在chef菜谱中包含模块时返回未初始化的常量错误

  •  0
  • aphexlog  · 技术社区  · 6 年前

    我有一个 java/recipes/windows 使用名为 win_friendly_path 赢得友谊之路 尚未定义。

    赢得友谊之路 ../windows/libraries/windows_helper.rb 具体如下:

    module Windows
      module Helper
    def win_friendly_path(path)
          path.gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR || '\\') if path
        end
    

    我已经有我的 berksfile metadata.rb 中的设置 java (./) windows 食谱。

    我不知道如何包括这个模块,所以现在我只是尝试使用 include WindowsHelper java/cookbook/windows

    uninitialized constant #<Class:#<Chef::Recipe:0x00000000029a2188>>::WindowsHelper

    我已经尝试了这方面的一些变化,现在觉得我花了太多的时间来解决这个问题,所以任何帮助是感激的。

    ::Chef::Resource.send(:include, Windows::Helper) java/配方/windows recipe给了我以下错误:

    Chef::Exceptions::ValidationFailed
           ----------------------------------
           value is a required property
    
    2 回复  |  直到 6 年前
        1
  •  1
  •   Ilya Konyukhov    6 年前

    试试这个

    include Windows::Helper
    
        2
  •  -1
  •   aphexlog    6 年前

    ::Chef::Recipe.send(:include, Windows::Helper)

    这允许我使用windows cookbook中的以下模块:

    module Windows
      module Helper
    ...
    {Variable}
      {Other_variable}
    ...
    
    推荐文章