I’m having trouble with my GitHub Action to test a Python module on Windows. To test the module, I need to install ffmpeg and make sure that it’s on Path but no matter what I do in the workflow file or the Python script that installs ffmpeg, I can’t seem to get it to appear on Path.
I’m installing ffmpeg through this script, which uses this approach to add it to Path:
def add_path_to_environment(path):
'''Adds a filepath to the users PATH variable after asking the user's consent'''
os_path = os.environ['path']
if not os_path.endswith(';'):
os_path += ';'
command = f'[Environment]::SetEnvironmentVariable("Path","{os_path}{path}","User")'
print('nn')
print(command)
print()
try:
subprocess.check_output(['powershell', command])
except subprocess.CalledProcessError as e:
print(e.stdout.decode())
My latest attempt in the workflow is to use this:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:FFMPEGbin", [System.EnvironmentVariableTarget]::User)
echo $env:Path
ffmpeg -version
Which I found here, but I’ve also tried just using $env:Path += ";C:FFMPEGbin"
Does anyone have any suggestions for how I could get ffmpeg on Path?