JanDeDobbeleer / oh-my-posh

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

Error with Git Bash (Windows): "syntax error near unexpected token `x86'" #1789

Closed RonAmihai closed 2 years ago

RonAmihai commented 2 years ago

Code of Conduct

What happened?

I'm using the latest version (7.20.0) on Windows 11 (build 22000.527) with Windows Terminal. PowerShell, PowerShell Core, WSL Ubuntu & WSL Arch are working as expected with oh-my-posh.

Whenever initializing oh-my-posh inside Git Bash (Windows), the following error appears:

bash: command substitution: line 2: syntax error near unexpected token `x86'
bash: command substitution: line 2: `C:/Program\ Files\ (x86)/oh-my-posh/bin/oh-my-posh.exe --millis > "$TIMER_START")'
bash: command substitution: line 1: syntax error near unexpected token `x86'
bash: command substitution: line 1: `C:/Program\ Files\ (x86)/oh-my-posh/bin/oh-my-posh.exe --millis > "$TIMER_START"'

It's probably due to missing quotes around the executable's path (which includes the "Program Files (x86)" folder name).

Manual Fix

Removing oh-my-posh and reinstalling it to a path without spaces (for example: "C:\oh-my-posh")

Theme

aliens theme

What OS are you seeing the problem on?

Windows

Which shell are you using?

bash

Log output

bash: command substitution: line 2: syntax error near unexpected token `x86'
bash: command substitution: line 2: `C:/Program\ Files\ (x86)/oh-my-posh/bin/oh-my-posh.exe --millis > "$TIMER_START")'
bash: command substitution: line 1: syntax error near unexpected token `x86'
bash: command substitution: line 1: `C:/Program\ Files\ (x86)/oh-my-posh/bin/oh-my-posh.exe --millis > "$TIMER_START"'

Version: 7.20.0

Segments:

ConsoleTitle(false) -   0 ms -
session(true)  -   0 ms -  ronam@RON-AM-PC 
path(true)     -   0 ms -  﩯
git(false)     -   8 ms -
shell(true)    -   0 ms -  uni

Run duration: 9.7595ms

Cache path: C:\Users\ronam\AppData\Local/oh-my-posh

Logs:

2022/02/19 22:10:49 Args duration: 0s, args:
2022/02/19 22:10:49 Args duration: 0s, args:
2022/02/19 22:10:49 Args duration: 0s, args:
2022/02/19 22:10:49 Shell duration: 0s, args:
2022/02/19 22:10:49 debug: Getenv

2022/02/19 22:10:49 Getenv duration: 0s, args: OMP_CACHE_DISABLED
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 debug: Home
C:\Users\ronam
2022/02/19 22:10:49 PathSeparator duration: 0s, args:
2022/02/19 22:10:49 PathSeparator duration: 0s, args:
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 debug: Home
C:\Users\ronam
2022/02/19 22:10:49 debug: Getenv

2022/02/19 22:10:49 Getenv duration: 0s, args: SSH_CONNECTION
2022/02/19 22:10:49 debug: Getenv

2022/02/19 22:10:49 Getenv duration: 0s, args: SSH_CLIENT
2022/02/19 22:10:49 Root duration: 0s, args:
2022/02/19 22:10:49 Shell duration: 0s, args:
2022/02/19 22:10:49 ErrorCode duration: 0s, args:
2022/02/19 22:10:49 IsWsl duration: 0s, args:
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 debug: Home
C:\Users\ronam
2022/02/19 22:10:49 PathSeparator duration: 0s, args:
2022/02/19 22:10:49 PathSeparator duration: 0s, args:
2022/02/19 22:10:49 User duration: 0s, args:
2022/02/19 22:10:49 Host duration: 0s, args:
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 TemplateCache duration: 0s, args:
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 debug: Home
C:\Users\ronam
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 Args duration: 0s, args:
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 debug: Home
C:\Users\ronam
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 PathSeparator duration: 0s, args:
2022/02/19 22:10:49 Args duration: 0s, args:
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 debug: Home
C:\Users\ronam
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 PathSeparator duration: 0s, args:
2022/02/19 22:10:49 PathSeparator duration: 0s, args:
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 IsWsl duration: 0s, args:
2022/02/19 22:10:49 StackCount duration: 0s, args:
2022/02/19 22:10:49 TemplateCache duration: 0s, args:
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 debug: Home
C:\Users\ronam
2022/02/19 22:10:49 GOOS duration: 0s, args:
2022/02/19 22:10:49 HasCommand duration: 8.5084ms, args: git.exe
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 error: HasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/02/19 22:10:49 HasParentFilePath duration: 0s, args: .git
2022/02/19 22:10:49 debug: Pwd
C:\Users\ronam
2022/02/19 22:10:49 Pwd duration: 0s, args:
2022/02/19 22:10:49 debug: Home
C:\Users\ronam
2022/02/19 22:10:49 Shell duration: 0s, args:
2022/02/19 22:10:49 TemplateCache duration: 0s, args:
2022/02/19 22:10:49 debug: Getenv
C:\Users\ronam\AppData\Local
2022/02/19 22:10:49 Getenv duration: 0s, args: LOCALAPPDATA
2022/02/19 22:10:49 CachePath duration: 0s, args:
RonAmihai commented 2 years ago

Update: Removing oh-my-posh and reinstalling it to a path without spaces (for example, "C:\oh-my-posh") fixes the issue.

RonAmihai commented 2 years ago

Unfortunately, the fix doesn't seem to resolve the issue. I've installed version 7.21.0 to the default path (Program Files x86).

And still, executing eval "$(oh-my-posh --init --shell bash --config ~/cli-theme.omp.json)" in Git Bash gives the following error:

bash: command substitution: line 19: syntax error near unexpected token `x86'
bash: command substitution: line 19: `C:/Program\ Files\ (x86)/oh-my-posh/bin/oh-my-posh.exe --config="$POSH_THEME" --shell=bash --print-secondary)"'
bash: command substitution: line 37: syntax error near unexpected token `('
bash: command substitution: line 37: `command -v C:/Program\ Files\ (x86)/oh-my-posh/bin/oh-my-posh.exe)"'
bash: syntax error near unexpected token `x86'

Log output:

$ oh-my-posh --debug --shell uni --config="$POSH_THEME"
bash: command substitution: line 6: syntax error near unexpected token `x86'
bash: command substitution: line 6: `C:/Program\ Files\ (x86)/oh-my-posh/bin/oh-my-posh.exe --millis > "$TIMER_START")'
bash: command substitution: line 1: syntax error near unexpected token `x86'
bash: command substitution: line 1: `C:/Program\ Files\ (x86)/oh-my-posh/bin/oh-my-posh.exe --millis > "$TIMER_START"'

Version: 7.21.0

Segments:

ConsoleTitle(false) -   0 ms -
session(true)  -   0 ms -  ronam@RON-AM-PC 
path(true)     -   0 ms -  﩯
git(false)     -   1 ms -
shell(true)    -   0 ms -  uni

Run duration: 2.1613ms

Cache path: C:\Users\ronam\AppData\Local/oh-my-posh

Logs:

2022/02/20 17:48:14 Args duration: 0s, args:
2022/02/20 17:48:14 Args duration: 0s, args:
2022/02/20 17:48:14 Args duration: 0s, args:
2022/02/20 17:48:14 Shell duration: 0s, args:
2022/02/20 17:48:14 debug: Getenv

2022/02/20 17:48:14 Getenv duration: 0s, args: OMP_CACHE_DISABLED
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 debug: Home
C:\Users\ronam
2022/02/20 17:48:14 PathSeparator duration: 0s, args:
2022/02/20 17:48:14 PathSeparator duration: 0s, args:
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 debug: Home
C:\Users\ronam
2022/02/20 17:48:14 debug: Getenv

2022/02/20 17:48:14 Getenv duration: 0s, args: SSH_CONNECTION
2022/02/20 17:48:14 debug: Getenv

2022/02/20 17:48:14 Getenv duration: 0s, args: SSH_CLIENT
2022/02/20 17:48:14 Root duration: 0s, args:
2022/02/20 17:48:14 Shell duration: 0s, args:
2022/02/20 17:48:14 ErrorCode duration: 0s, args:
2022/02/20 17:48:14 IsWsl duration: 0s, args:
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 debug: Home
C:\Users\ronam
2022/02/20 17:48:14 PathSeparator duration: 0s, args:
2022/02/20 17:48:14 PathSeparator duration: 0s, args:
2022/02/20 17:48:14 User duration: 0s, args:
2022/02/20 17:48:14 Host duration: 0s, args:
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 TemplateCache duration: 0s, args:
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 debug: Home
C:\Users\ronam
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 Args duration: 0s, args:
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 debug: Home
C:\Users\ronam
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 PathSeparator duration: 0s, args:
2022/02/20 17:48:14 Args duration: 0s, args:
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 debug: Home
C:\Users\ronam
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 PathSeparator duration: 0s, args:
2022/02/20 17:48:14 PathSeparator duration: 0s, args:
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 IsWsl duration: 0s, args:
2022/02/20 17:48:14 StackCount duration: 0s, args:
2022/02/20 17:48:14 TemplateCache duration: 0s, args:
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 debug: Home
C:\Users\ronam
2022/02/20 17:48:14 GOOS duration: 0s, args:
2022/02/20 17:48:14 HasCommand duration: 548.8µs, args: git.exe
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 error: HasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/02/20 17:48:14 HasParentFilePath duration: 551.3µs, args: .git
2022/02/20 17:48:14 debug: Pwd
C:\Users\ronam
2022/02/20 17:48:14 Pwd duration: 0s, args:
2022/02/20 17:48:14 debug: Home
C:\Users\ronam
2022/02/20 17:48:14 Shell duration: 0s, args:
2022/02/20 17:48:14 TemplateCache duration: 0s, args:
2022/02/20 17:48:14 debug: Getenv
C:\Users\ronam\AppData\Local
2022/02/20 17:48:14 Getenv duration: 0s, args: LOCALAPPDATA
2022/02/20 17:48:14 CachePath duration: 0s, args:
JanDeDobbeleer commented 2 years ago

@RonAmihai you need 7.21.1

RonAmihai commented 2 years ago

@RonAmihai you need 7.21.1

Apologies, my mistake. Thanks!

github-actions[bot] commented 8 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.