px
px copied to clipboard
v0.9.2 - px.ini created in the directory of process caller and not in the one of px.exe
I have automated the configuration of px through a PowerShell script.
$startParams = @{
FilePath = "C:\mypath\px\px.exe"
ArgumentList = "--server=$proxy", "--listen=$localHost", "--port=$localPort", "--noproxy=$noProxy", "--workers=4", "--save"
WindowStyle = "Hidden"
}
Start-Process @startParams | Out-Null
Px generates a px.ini
file but in the directory from where the PowerShell script has been launched.
For example if the powsershell script is executed from the C:\anotherdirectory the px.ini
file will be created in the anotherdirectory
and not in the intended C:\mypath\px
.
I see you are using the getcwd
function to create px.ini
file: https://github.com/genotrance/px/blob/07b6668a2962011bd61fc31c3c9f37ae5e2f5111/px/config.py#L720C9-L732C40
Is it the expected behavior?
PS: I did a workaround by adding the WorkingDirectory
path option to override the working directory of the Start-Process
command.
The px.ini configuration loading order was changed in v0.9.0:
- Changed loading order of px.ini - from CLI flag first, environment next, working directory and finally from the Px directory
You could also add the --config
flag to point to another location.
There is an open bug though that needs to be fixed: #213
Wouldn't be better in term of UX to create a px.ini in the directory of the px.exe
while using --save
option? And to use another option to override the default location mentioned previously?
Problem is that binary can be in a read/only or admin location whereas config files are user specific. Working directory was preferred for that reason.
It is a change from legacy behavior.
Related: https://github.com/genotrance/px/issues/189.