Skip to content

Use-PodeScript with relative, naked path resolves wrongly and fails when run from VS Code terminal started in another directory #1582

@helpimnotdrowning

Description

@helpimnotdrowning

Describe the Bug

When Use-PodeScript is used with a relative, "naked" path, ex Use-PodeScript -Path functions.ps1, the server resolved the path incorrectly and subsequently fails to start, but only when run within the VS Code integrated terminal started in a different directory.

There is no issue when instead using ./functions.ps1.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a directory structure like
~/
  + Example/
    + Server/
      o server.ps1
      o functions.ps1

, where server.ps1 is

Import-Module pode

Start-PodeServer {
    Use-PodeScript -Path functions.ps1
}

and functions.ps1 can be empty (it just has to exist)
2. Open VS Code to the Example directory (or any directory that is not ~/Example/Server or a child of it)
3. Open the integrated terminal and cd to the Server directory.
4. Run server.ps1 and observe the error

Exception: /home/helpimnotdrowning/.local/share/powershell/Modules/Pode/2.12.1/Public/Utilities.ps1:213:9
Line |
 213 |          throw ($PodeLocale.scriptPathDoesNotExistExceptionMessage -f  …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The script path does not exist: /home/helpimnotdrowning/Example/functions.ps1

, where Use-PodeScript (internal Get-PodeRelativePath) has wrongly resolved the location of functions.ps1.

Expected Behavior

File in my example is resolved correctly to /home/helpimnotdrowning/Shirakami/Utatane/functions.ps1

Screenshots

pode_vscodebug.mp4

Platform

  • OS: Linux, Debian 12
  • Browser: n/a
  • Versions:
    • Pode: 2.12.1
    • PowerShell: 7.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions