Module: ChefUtils::DSL::DefaultPaths

Extended by:
DefaultPaths
Includes:
Internal
Included in:
ChefUtils, DefaultPaths, PathSanity
Defined in:
lib/chef-utils/dsl/default_paths.rb

Instance Method Summary collapse

Instance Method Details

#default_paths(env = nil) ⇒ Object

Since:

  • 15.5



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/chef-utils/dsl/default_paths.rb', line 28

def default_paths(env = nil)
  env_path = env ? env["PATH"] : __env_path
  env_path = "" if env_path.nil?
  path_separator = ChefUtils.windows? ? ";" : ":"
  # ensure the Ruby and Gem bindirs are included for omnibus chef installs
  new_paths = env_path.split(path_separator)
  [ __ruby_bindir, __gem_bindir ].compact.each do |path|
    new_paths = [ path ] + new_paths unless new_paths.include?(path)
  end
  __default_paths.each do |path|
    new_paths << path unless new_paths.include?(path)
  end
  new_paths.join(path_separator).encode("utf-8", invalid: :replace, undef: :replace)
end