intellij-powershell
intellij-powershell copied to clipboard
Run configuration working directory and relative paths
Hi,
as requested here is some further explaining of my comments made in #22 Note I am using Windows 10 and pycharm 2021.1.2 professional.
When I initially created my config file (leaving everything blank as shown below)

it creates a config file with the following content
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test_script.ps1" type="PowerShellRunType" factoryName="PowerShell"
scriptUrl="$PROJECT_DIR$/test_rel_ps_path/test_script.ps1" workingDirectory="C:\Users\Kristoffer"
executablePath="$PROJECT_DIR$/../../../Windows/System32/WindowsPowerShell/v1.0/powershell.exe">
<envs/>
<method v="2"/>
</configuration>
</component>
Which automatically inserts my windows user profile directory, even though default project directory is set to the following

and my test_script.ps1 is just
$a = Get-Location
Write-Output $a
which returns

if I try to set the work dir to its relative parent directory like so

I end up with a dir inside my pycharm installation directory

However, it works as intended whenever I pass an absolute path

If I try to manually define $PROJECT_DIR$:

I end up with the following error

So from what I can tell the leaving the working directory blank returns the user directory and relative paths are relative to a folder inside the pycharm installation folder.
Could it be a bug in pycharm or is there something that can be done in the plugin or is it simply me not understanding how it all connects? :)
Best Regards Kristoffer