JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
16.79k stars 2.35k forks source link

Failed to detour process #1434

Closed Ar5ham closed 2 years ago

Ar5ham commented 2 years ago

Code of Conduct

What happened?

In the most recent version of the Oh-my-posh with Windows Terminal Preview Version: 1.12.2931.0, I am getting the following error in my compile windows. The moment I add Import-Module oh-my-posh to the $Profile this error shows up, even if I don't set a theme. If I removed the import the error doesn't repro again, which I find very odd.

3004>errors in directory g:\ .....
3004>(TRACELOG)error (CreateDetouredProcessW): Failed to detour process. [appName]: (null), [cmdLine]: "C:\Users\<WINDOWSUSERNAME>\Documents\PowerShell\Modules\oh-my-posh\oh-my-posh.exe" --version, [Error Code]: 6
3004>(TRACELOG)error (CreateDetouredProcessW): Failed to detour process. [appName]: (null), [cmdLine]: "C:\Users\<WINDOWSUSERNAME>\DOCUME~1\POWERS~1\Modules\OH-MY-~1\OH-MY-~1.EXE" "C:\Users\<WINDOWSUSERNAME>\Documents\PowerShell\Modules\oh-my-posh\oh-my-posh.exe" --version, [Error Code]: 6
3004>(TRACELOG)error (CreateDetouredProcessW): Failed to detour process. [appName]: (null), [cmdLine]: "C:\Users\<WINDOWSUSERNAME>\Documents\PowerShell\Modules\oh-my-posh\oh-my-posh.exe" --init --shell pwsh --config ~/Documents/PowerShell/Modules/oh-my-posh/themes/jandedobbeleer.omp.json, [Error Code]: 63004>(TRACELOG)error (CreateDetouredProcessW): Failed to detour process. [appName]: (null), [cmdLine]: "C:\Users\<WINDOWSUSERNAME>\DOCUME~1\POWERS~1\Modules\OH-MY-~1\OH-MY-~1.EXE" "C:\Users\<WINDOWSUSERNAME>\Documents\PowerShell\Modules\oh-my-posh\oh-my-posh.exe" --init --shell pwsh --config ~/Documents/PowerShell/Modules/oh-my-posh/themes/jandedobbeleer.omp.json, [Error Code]: 6

This is another error instance when I am compiling an open source project, Newtonsoft.Json

3001>errors in directory g:\opensource\newtonsoft.json
3001>(TRACELOG)error (CreateDetouredProcessW): Failed to detour process. [appName]: (null), [cmdLine]: "C:\Users\<WINDOWSUSERNAME>\Documents\PowerShell\Modules\oh-my-posh\oh-my-posh.exe" --version, [Error Code]: 6 [g:\opensource\Newtonsoft.Json\newtonsoft.json.testnet.csproj]
3001>(TRACELOG)error (CreateDetouredProcessW): Failed to detour process. [appName]: (null), [cmdLine]: "C:\Users\<WINDOWSUSERNAME>\DOCUME~1\POWERS~1\Modules\OH-MY-~1\OH-MY-~1.EXE" "C:\Users\<WINDOWSUSERNAME>\Documents\PowerShell\Modules\oh-my-posh\oh-my-posh.exe" --version, [Error Code]: 6 [g:\opensource\Newtonsoft.Json\newtonsoft.json.testnet.csproj]
3001>g:\os2\src\tools\microsoft.build.common.targets(968,5) : error MSB3073: The command "g:\os2\tools\binplace\binplace.exe /R g:\os2\bin\amd64fre\. /s g:\os2\bin\amd64fre\Symbols.pri\. /j /:DBG /:NOCV  -:LOGPDB /:CVTCIL /:DEST retail    @g:\opensource\newtonsoft.json\objfre\amd64\binplace_compiled.rsp" exited with code -1. [g:\opensource\Newtonsoft.Json\newtonsoft.json.testnet.csproj]
3001>Compiling g:\opensource\boost\libs\serialization\src [68%]
3001>msbuild.cmd "newtonsoft.json.testnet.csproj" /nologo /p:BuildingInSeparatePasses=true /p:BuildingWithBuildExe=true /clp:NoSummary /verbosity:normal /Target:BuildCompiled /p:Pass=Compile /p:ObjectPath=g:\obj\amd64fre\opensource\newtonsoft.json\ failed - rc = 0x00000001
>  Get-InstalledModule

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
6.32.5               oh-my-posh                          PSGallery            A prompt theme engine for any shell
2.2.0-beta4          PSReadLine                          PSGallery            Great command line editing in the PowerS…
0.2.2                Terminal-Icons                      PSGallery            PowerShell module to add file icons to t…
2.2.16               VSSetup                             PSGallery            Visual Studio Setup PowerShell Module

This is the $profile at the moment:

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme agnoster
#oh-my-posh --init --shell pwsh --config ~/Documents/PowerShell/Modules/oh-my-posh/themes/jandedobbeleer.omp.json | Invoke-Expression
Import-Module -Name Terminal-Icons

I'm not 100% sure if this is a Terminal/windows issue or oh-my-posh issue at the moment but it consistently repros on my build PS terminal. will be happy to provide additional info if it helps debugging this.

Theme

I have used both of the following in my $profile (One at the time not both together) Set-PoshPrompt -Theme agnoster oh-my-posh --init --shell pwsh --config ~/Documents/PowerShell/Modules/oh-my-posh/themes/jandedobbeleer.omp.json | Invoke-Expression However this issue repros even without setting a theme.

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

oh-my-posh --debug --shell uni --config="$POSH_THEME"

Version: 6.32.5

Segments:

ConsoleTitle(true) -   0 ms -
session(true)  -   0 ms -  ar5ham@<MACHINE_NAME> 
path(true)     -   0 ms -   opensource 
git(true)      -  16 ms -  <TEST_BRANCH> 
battery(false) -   3 ms -
node(false)    -   1 ms -
shell(true)    -   0 ms -  ﲵ uni 
root(true)     -   0 ms -   
text(true)     -   0 ms -  NO CONFIG 
exit(true)     -   0 ms -   

Run duration: 22.7147ms

Logs:

2021/12/14 13:43:48 debug: getenv
C:\Users\arsham\AppData\Local
2021/12/14 13:43:48 getenv duration: 0s, args: LOCALAPPDATA
2021/12/14 13:43:48 getCachePath duration: 0s, args:
2021/12/14 13:43:48 getArgs duration: 0s, args:
2021/12/14 13:43:48 getArgs duration: 0s, args:
2021/12/14 13:43:48 getShellName duration: 0s, args:
2021/12/14 13:43:48 debug: getenv

2021/12/14 13:43:48 getenv duration: 0s, args: OMP_CACHE_DISABLED
2021/12/14 13:43:48 isRunningAsRoot duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getShellName duration: 0s, args:
2021/12/14 13:43:48 getCurrentUser duration: 0s, args:
2021/12/14 13:43:48 getHostName duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 debug: getenv

2021/12/14 13:43:48 getenv duration: 0s, args: SSH_CONNECTION
2021/12/14 13:43:48 debug: getenv

2021/12/14 13:43:48 getenv duration: 0s, args: SSH_CLIENT
2021/12/14 13:43:48 getCurrentUser duration: 0s, args:
2021/12/14 13:43:48 getRuntimeGOOS duration: 0s, args:
2021/12/14 13:43:48 getHostName duration: 0s, args:
2021/12/14 13:43:48 debug: getenv

2021/12/14 13:43:48 getenv duration: 0s, args: POSH_SESSION_DEFAULT_USER
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getArgs duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getRuntimeGOOS duration: 0s, args:
2021/12/14 13:43:48 getRuntimeGOOS duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getRuntimeGOOS duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getRuntimeGOOS duration: 0s, args:
2021/12/14 13:43:48 hasCommand duration: 16.8699ms, args: git.exe
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 hasParentFilePath duration: 0s, args: .git
2021/12/14 13:43:48 getFileContent duration: 545.8µs, args: G:\.git/HEAD
2021/12/14 13:43:48 error: getFileContent
open G:\.git/logs/refs/stash: The system cannot find the file specified.
2021/12/14 13:43:48 getFileContent duration: 0s, args: G:\.git/logs/refs/stash
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getBatteryInfo duration: 3.7764ms, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 hasFiles duration: 517.5µs, args: *.js
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 hasFiles duration: 0s, args: *.ts
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 hasFiles duration: 0s, args: package.json
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 hasFiles duration: 0s, args: .nvmrc
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 hasFiles duration: 0s, args: pnpm-workspace.yaml
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 hasFiles duration: 1.0051ms, args: .pnpmfile.cjs
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 hasFiles duration: 0s, args: .npmrc
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getShellName duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 isRunningAsRoot duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 isRunningAsRoot duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getPathSeperator duration: 0s, args:
2021/12/14 13:43:48 getShellName duration: 0s, args:
2021/12/14 13:43:48 getCurrentUser duration: 0s, args:
2021/12/14 13:43:48 getHostName duration: 0s, args:
2021/12/14 13:43:48 getcwd duration: 0s, args:
2021/12/14 13:43:48 lastErrorCode duration: 0s, args:
JanDeDobbeleer commented 2 years ago

@Ar5ham what command do you use so I can reproduce this?

Ar5ham commented 2 years ago

what command do you use so I can reproduce this?

Command for compiling? or something else?

JanDeDobbeleer commented 2 years ago

@Ar5ham yes, I'm looking for the exact steps to reproduce (for example with newtonsoft.json).

Ar5ham commented 2 years ago

The build command is kind of abstracted via a cmd, had to go dig it out. Try this one 👇🏽👇🏽

msbuild.exe "newtonsoft.json.testnet.csproj" /nologo /p:BuildingInSeparatePasses=true /p:BuildingWithBuildExe=true /p:Test_Code=1 /clp:NoSummary /verbosity:normal /Target:BuildGenerated /p:Pass=Generate /p:ObjectPath=g:\opensource\newtonsoft.json\ /p:TARGET_PLATFORM=windows /p:THREAD_ID=2
Ar5ham commented 2 years ago

@JanDeDobbeleer I updated the oh-my-posh module on PS (below are the versions) and I can't repro the issue anymore. Perhaps we can close this for now. Both 6.41 and 6.44.1 don't repro this issue anymore. Windows didn't update/upgrade in between.

❯ Get-InstalledModule

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
6.44.1               oh-my-posh                          PSGallery            A prompt theme engine for any shell
1.0.0                posh-git                            PSGallery            Provides prompt with Git status summary information and tab completion for Git commands, parameters, remotes and branch names.
0.8.0                Terminal-Icons                      PSGallery            PowerShell module to add file icons to terminal based on file extension
2.2.16               VSSetup                             PSGallery            Visual Studio Setup PowerShell Module
github-actions[bot] commented 6 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.