PowerShell / PowerShell/DSC

when using `-p` to pass a file `~` cannot be used in PowerShell

Open
#365 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Resolution-External
Dominant language
Rust
Stars
523
Forks
75
Avg merge
3d 16h
Merged PRs (30d)
24

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.
Steps to reproduce

When testing out the new parameter -p and -path inside PowerShell I was unable to use the ~ for referencing the $HOME location, while $env:USERPROFILE worked as seen below. The tilde can be used with other commands like Get-Command, so I was expecting this to work as an alias for the user profile.

Expected behavior
dsc config get --path ~\gotstoy.dsc.config.yaml
results:
- name: All Users Configuration
  type: TSToy.Example/gotstoy
  result:
    actualState:
      ensure: present
      scope: machine
      updateAutomatically: true
      updateFrequency: 23
- name: Current User Configuration
  type: TSToy.Example/gotstoy
  result:
    actualState:
      ensure: present
      scope: user
      updateAutomatically: true
messages: []
hadErrors: false
Actual behavior
dsc config get --path ~\gotstoy.dsc.config.yaml
2024-03-16T23:59:13.854146Z ERROR dsc::util: 385: Error: Failed to read input file: The system cannot find the path specified. (os error 3)
Error details

No response

Environment data
Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Version

dsc 3.0.0-alpha.5

Visuals
image

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

Reproduce dsc config get --path ~\gotstoy.dsc.config.yaml in PowerShell using the environment details provided, then trace how the CLI handles the --path/-p argument. Done means the command resolves ~ to the user profile and produces the expected configuration result without the path error.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.