|
I am trying to call I install like this: sudo apt install ffmpeg python3 python3-pip python3-venv build-essential pipx
pipx ensurepath
pipx install whisper-ctranslate2
pipx list
which whisper-ctranslate2
command -v whisper-ctranslate2
whisper-ctranslate2 --helpThis works fine, and when I SSH remove VSCode to the machine it also works fine when called from the VSCode terminal: $ which whisper-ctranslate2
/home/pieter/.local/bin/whisper-ctranslate2
$ command -v whisper-ctranslate2
/home/pieter/.local/bin/whisper-ctranslate2
$ whisper-ctranslate2 --help
usage: whisper-ctranslate2 [-h]And the "executable" #!/home/pieter/.local/share/pipx/venvs/whisper-ctranslate2/bin/python
import sys
from whisper_ctranslate2.whisper_ctranslate2 import main
if __name__ == '__main__':
if sys.argv[0].endswith('.exe'):
sys.argv[0] = sys.argv[0][:-4]
sys.exit(main())When I call CliWrap with just the 14:17:52 [ERR] <1> "ExecuteAsync"
System.ComponentModel.Win32Exception (2): Failed to start a process with file path 'whisper-ctranslate2'. Target file or working directory doesn't exist, the provided credentials are invalid, or the resource policy cannot be set due to insufficient permissions. See the inner exception for more information. ---> System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'whisper-ctranslate2' with working directory '/home/pieter/AudioCleaner/AudioCleaner/bin/Debug/net10.0'. No such file or directory
at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at CliWrap.Utils.ProcessEx.Start(Action`1 configureProcess) in /_/CliWrap/Utils/ProcessEx.cs:line 69
at CliWrap.Utils.ProcessEx.Start(Action`1 configureProcess) in /_/CliWrap/Utils/ProcessEx.cs:line 79
at CliWrap.Command.ExecuteAsync(Action`1 configureStartInfo, Action`1 configureProcess, CancellationToken forcefulCancellationToken, CancellationToken gracefulCancellationToken) in /_/CliWrap/Command.Execution.cs:line 322
at CliWrap.Command.ExecuteAsync(CancellationToken forcefulCancellationToken, CancellationToken gracefulCancellationToken) in /_/CliWrap/Command.Execution.cs:line 378
at CliWrap.Buffered.BufferedCommandExtensions.ExecuteBufferedAsync(Command command, Encoding standardOutputEncoding, Encoding standardErrorEncoding, CancellationToken forcefulCancellationToken, CancellationToken gracefulCancellationToken) in /_/CliWrap/Buffered/BufferedCommandExtensions.cs:line 44
at CliWrap.Buffered.BufferedCommandExtensions.ExecuteBufferedAsync(Command command, Encoding standardOutputEncoding, Encoding standardErrorEncoding, CancellationToken cancellationToken) in /_/CliWrap/Buffered/BufferedCommandExtensions.cs:line 95
at CliWrap.Buffered.BufferedCommandExtensions.ExecuteBufferedAsync(Command command, Encoding encoding, CancellationToken cancellationToken) in /_/CliWrap/Buffered/BufferedCommandExtensions.cs:line 116
at CliWrap.Buffered.BufferedCommandExtensions.ExecuteBufferedAsync(Command command, CancellationToken cancellationToken) in /_/CliWrap/Buffered/BufferedCommandExtensions.cs:line 132
at Whisper.Version(CancellationToken cancellationToken) in /home/pieter/AudioCleaner/AudioCleaner/Whisper.cs:line 56
at AudioCleaner.Program.ExecuteAsync() in /home/pieter/AudioCleaner/AudioCleaner/Program.cs:line 43
14:17:52 [FTL] <1> Exception during processing.To fix it I must explicitly call the absolute path: public static async Task<int> Version(CancellationToken cancellationToken)
{
// command -v whisper-ctranslate2
// /home/pieter/.local/bin/whisper-ctranslate2
string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
string whisper = Path.Combine(home, ".local", "bin", "whisper-ctranslate2");
// string whisper = "whisper-ctranslate2";
Log.Debug("Whisper path: {Whisper}", whisper);
BufferedCommandResult result = await Cli.Wrap(whisper)
.WithArguments(args => args.Add("--version"))
.ExecuteBufferedAsync(cancellationToken);
return result.ExitCode;
}This makes it machine and user specific, how can I call the "executable" in the same way the shell would call it without needing to create an absolute path? |
Replies: 1 comment 2 replies
|
Does the regular I've previously introduced this file path resolving strategy, but thought it was only needed on Windows: CliWrap/CliWrap/Command.Execution.cs Lines 17 to 75 in fdf4bce |
Apologies for delay, I had claude create a quick test for me, looks like it is the vscode debugger not picking up the local user environment:
I built a minimal repro to compare
System.Diagnostics.ProcessvsCliWrapside-by-side on Debian 13 / .NET 10, callingwhisper-ctranslate2 --versionfour ways.Test code