chef / chef/chef-web-docs

Create windows path example using other system variable

Open
#985 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Aspect: Documentation Component: Chef Infra Client
Dominant language
HTML
Stars
143
Forks
438
Avg merge
1d 10h
Merged PRs (30d)
16

Description

This is for the windows_path resource. I am using Chef 12, but I read that it has moved to Chef by version 13.

Usecase: I wanted to add to the %PATH% something under local appdata on Windows. I tried referring to %LOCALAPPDATA% but found out that Windows system variables cannot include other system variables - https://superuser.com/questions/27826/why-cant-windows-handle-an-environment-variable-in-path

I ended up with reading %LOCALAPPDATA% and adding it to a string. Something like this:

my_path = "#{ENV['LOCALAPPDATA']}\\Apps\\OpenCover"

windows_path my_path do
  action :add
  notifies :request_reboot, 'reboot[Path updated]'
end

reboot 'Path updated' do
  action :nothing
end

I think it would be a good example. I am not sure if the above approach can be done smarter though.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the windows_path resource documentation and review its existing examples. Add a Windows example that reads LOCALAPPDATA and uses it to build the path, then confirm the example explains the intended PATH update and reboot notification behavior.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.