Closed FernandoBorea closed 2 years ago
@FernandoBorea that's probably a bug, I'll check.
Thanks!
I also checked that somehow I ended up with v6.17 on the installation that worked, and after updating it seems to be working fine with v6.19, but on the computer where I had the issue, it installed v6.19 right away and presented the issue.
@FernandoBorea that makes no sense at all, I just did an update and it all works. I'll try a clean install (but that shouldn't make a difference looking at the reported error tbh, both files are the same on update...)
I can't reproduce this:
Can you try to install again? Maybe something went wrong in the underlying PowerShell install logic?
I just tried to replicate it and it keeps happening, however, I ran the command Install-Module -Name oh-my-posh -RequiredVersion 6.17.0
to force install a previous version and it works just fine. I'll record a short video showing the issue, hold on a few minutes
@FernandoBorea that's mighty nice of you, but if I can't reproduce it, I can't fix it. Can you run this command and paste your clipboard here: Get-Content "$((Get-Module oh-my-posh).ModuleBase)\oh-my-posh.psm1" | clip
https://www.loom.com/share/b51eb19436794670bebf3d8cbd0ec98c Here's the video :) the command you posted here says the directory doesn't exists
As you can see here, I forced to install 6.17 which worked just fine, then I updated to 6.19 and this time it worked too without issues, it just happens when I install 6.19 right away. I show some attempts without admin privileges just in case it helps to narrow something down :) https://www.loom.com/share/c7834f69dbe642f29ee0a967ab87cb6d
Oh, never mind, it also breaks when updating to 6.19 after reloading PS
Deleted the 6.19 folder and opened a new PS terminal, it worked fine:
I just tried on the computer where I installed it at first, it also breaks, it seems I hadn't restarted PS, somehow I got 6.17 first there so it worked just fine at first but broke after updating it. Hope the feedback is useful!
@FernandoBorea the feedback is useful but not reproducible at all. Can you manually navigate to the folder containing 6.19.0 and provide me with all of its content?
@FabianEscarate found it, crashes on PowerShell 5....I'm close to dropping support for that ancient tool...
Sure, here it is:
PSD1:
#
# Module manifest for module 'oh-my-posh'
#
# Generated by: Jan De Dobbeleer
#
# Generated on: 11-Sep-20
#
@{
# Version number of this module.
ModuleVersion = '6.19.0'
# Script module or binary module file associated with this manifest.
RootModule = 'oh-my-posh.psm1'
# ID used to uniquely identify this module
GUID = '7d7c4a78-e2fe-4e5f-9510-34ac893e4562'
# Company or vendor of this module
CompanyName = 'Unknown'
# Author of this module
Author = 'Jan De Dobbeleer'
# Copyright statement for this module
Copyright = '(c) 2020 Jan De Dobbeleer. All rights reserved.'
# Description of the functionality provided by this module
Description = 'A prompt theme engine for any shell'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'
# List of all files packaged with this module
FileList = @()
# Cmdlets to export from this module
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = @()
# Aliases to export from this module
AliasesToExport = '*'
# Functions to export from this module
FunctionsToExport = @('Set-PoshPrompt')
# Private data to pass to the module specified in RootModule. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('git', 'agnoster', 'theme', 'zsh', 'posh-git', 'prompt', 'paradox', 'robbyrussel', 'oh-my-posh')
# A URL to the license for this module.
LicenseUri = 'https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/COPYING'
# A URL to the main website for this project.
ProjectUri = 'https://github.com/JanDeDobbeleer/oh-my-posh'
} # End of PSData hashtable
} # End of PrivateData hashtable
}
PSM1:
$env:POSH_PATH = "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName)"
$env:POSH_THEMES_PATH = $env:POSH_PATH + "/themes"
$env:PATH = "$env:POSH_PATH;$env:PATH"
function Get-PoshDownloadUrl {
param(
[Parameter(Mandatory = $true)]
[string]
$Version
)
$executable = ""
if ($IsMacOS) {
$executable = "posh-darwin-amd64"
}
elseif ($IsLinux) {
# this is rather hacky but there's no other way for the time being
$arch = uname -m
if ($arch -eq 'aarch64') {
$executable = "posh-linux-arm64"
}
elseif ($arch -eq 'armv7l') {
$executable = "posh-linux-arm"
}
else {
$executable = "posh-linux-amd64"
}
}
else {
$arch = (Get-CimInstance -Class Win32_Processor -Property Architecture).Architecture
switch ($arch) {
0 { $executable = "posh-windows-386.exe" } # x86
5 { $executable = "posh-windows-arm64.exe" } # ARM
9 { $executable = "posh-windows-amd64.exe" } # x64
12 { $executable = "posh-windows-amd64.exe" } # x64 emulated on Surface Pro X
}
}
if ($executable -eq "") {
throw "oh-my-posh: Unsupported architecture: $arch"
}
return "https://github.com/jandedobbeleer/oh-my-posh/releases/download/v$Version/$executable"
}
function Get-PoshExecutable {
param(
[Parameter(Mandatory = $true)]
[string]
$Url,
[Parameter(Mandatory = $true)]
[string]
$Destination
)
Invoke-WebRequest $Url -Out $Destination
if (-Not (Test-Path $executable)) {
# This should only happen with a corrupt installation
throw "Executable at $executable was not found, please try importing oh-my-posh again."
}
# Set the right binary to executable before doing anything else
# Permissions don't need to be set on Windows
if ($PSVersionTable.PSEdition -ne "Core" -or $IsWindows) {
return
}
chmod a+x $executable 2>&1
}
function Get-PoshCommand {
$extension = ""
if ($PSVersionTable.PSEdition -ne "Core" -or $IsWindows) {
$extension = ".exe"
}
return "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase).Parent.FullName)/oh-my-posh$extension"
}
function Sync-PoshThemes {
param(
[Parameter(Mandatory = $true)]
[string]
$Version
)
Write-Host "Downloading oh-my-posh themes for $Version"
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } –PassThru
$themesUrl = "https://github.com/jandedobbeleer/oh-my-posh/releases/download/v$Version/themes.zip"
Invoke-WebRequest -OutFile $tmp $themesUrl
$destination = $env:POSH_THEMES_PATH
$tmp | Expand-Archive -DestinationPath $destination -Force
$tmp | Remove-Item
}
function Sync-PoshArtifacts {
param(
[Parameter(Mandatory = $true)]
[string]
$Version
)
$executable = Get-PoshCommand
if (-not (Test-Path $executable)) {
Write-Host "Downloading oh-my-posh executable for $Version"
$url = Get-PoshDownloadUrl -Version $Version
Get-PoshExecutable -Url $url -Destination $executable
Sync-PoshThemes -Version $Version
return
}
$poshVersion = & $executable --version
if ($poshVersion -eq $Version) {
return
}
Write-Host "Updating oh-my-posh executable to $Version"
$url = Get-PoshDownloadUrl -Version $Version
Get-PoshExecutable -Url $url -Destination $executable
Sync-PoshThemes -Version $Version
}
$moduleVersion = Split-Path -Leaf $MyInvocation.MyCommand.ScriptBlock.Module.ModuleBase
Sync-PoshArtifacts -Version $moduleVersion
# Legacy functions
function Set-PoshPrompt {
param(
[Parameter(Mandatory = $false)]
[string]
$Theme
)
$config = ""
if (Test-Path "$($env:POSH_THEMES_PATH)/$Theme.omp.json") {
$path = "$($env:POSH_THEMES_PATH)/$Theme.omp.json"
$config = (Resolve-Path -Path $path).ProviderPath
}
elseif (Test-Path $Theme) {
$config = (Resolve-Path -Path $Theme).ProviderPath
}
else {
$config = "$($env:POSH_THEMES_PATH)/jandedobbeleer.omp.json"
}
# Workaround for get-location/push-location/pop-location from within a module
# https://github.com/PowerShell/PowerShell/issues/12868
# https://github.com/JanDeDobbeleer/oh-my-posh2/issues/113
$global:omp_global_sessionstate = $PSCmdlet.SessionState
$poshCommand = Get-PoshCommand
(& $poshCommand --init --shell=pwsh --config="$config") | Invoke-Expression
}
XML:
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>Microsoft.PowerShell.Commands.PSRepositoryItemInfo</T>
<T>System.Management.Automation.PSCustomObject</T>
<T>System.Object</T>
</TN>
<MS>
<S N="Name">oh-my-posh</S>
<Version N="Version">6.19.0</Version>
<S N="Type">Module</S>
<S N="Description">A prompt theme engine for any shell</S>
<S N="Author">Jan De Dobbeleer</S>
<S N="CompanyName">janjoris</S>
<S N="Copyright">(c) 2020 Jan De Dobbeleer. All rights reserved.</S>
<DT N="PublishedDate">2021-11-29T15:26:02-06:00</DT>
<Obj N="InstalledDate" RefId="1">
<DT>2021-11-29T07:57:03.7396023-06:00</DT>
<MS>
<Obj N="DisplayHint" RefId="2">
<TN RefId="1">
<T>Deserialized.Microsoft.PowerShell.Commands.DisplayHintType</T>
<T>Deserialized.System.Enum</T>
<T>Deserialized.System.ValueType</T>
<T>Deserialized.System.Object</T>
</TN>
<ToString>DateTime</ToString>
<I32>2</I32>
</Obj>
</MS>
</Obj>
<Obj N="UpdatedDate" RefId="3">
<DT>2021-11-29T12:01:54.3846438-06:00</DT>
<MS>
<Obj N="DisplayHint" RefId="4">
<TN RefId="2">
<T>Microsoft.PowerShell.Commands.DisplayHintType</T>
<T>System.Enum</T>
<T>System.ValueType</T>
<T>System.Object</T>
</TN>
<ToString>DateTime</ToString>
<I32>2</I32>
</Obj>
</MS>
</Obj>
<URI N="LicenseUri">https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/COPYING</URI>
<URI N="ProjectUri">https://github.com/JanDeDobbeleer/oh-my-posh</URI>
<Nil N="IconUri" />
<Obj N="Tags" RefId="5">
<TN RefId="3">
<T>System.Object[]</T>
<T>System.Array</T>
<T>System.Object</T>
</TN>
<LST>
<S>git</S>
<S>agnoster</S>
<S>theme</S>
<S>zsh</S>
<S>posh-git</S>
<S>prompt</S>
<S>paradox</S>
<S>robbyrussel</S>
<S>oh-my-posh</S>
<S>PSModule</S>
</LST>
</Obj>
<Obj N="Includes" RefId="6">
<TN RefId="4">
<T>System.Collections.Hashtable</T>
<T>System.Object</T>
</TN>
<DCT>
<En>
<S N="Key">Function</S>
<Obj N="Value" RefId="7">
<TNRef RefId="3" />
<LST>
<S>Set-PoshPrompt</S>
</LST>
</Obj>
</En>
<En>
<S N="Key">RoleCapability</S>
<Obj N="Value" RefId="8">
<TNRef RefId="3" />
<LST />
</Obj>
</En>
<En>
<S N="Key">Command</S>
<Obj N="Value" RefId="9">
<TNRef RefId="3" />
<LST>
<S>Set-PoshPrompt</S>
</LST>
</Obj>
</En>
<En>
<S N="Key">DscResource</S>
<Obj N="Value" RefId="10">
<TNRef RefId="3" />
<LST />
</Obj>
</En>
<En>
<S N="Key">Workflow</S>
<Obj N="Value" RefId="11">
<TNRef RefId="3" />
<LST />
</Obj>
</En>
<En>
<S N="Key">Cmdlet</S>
<Obj N="Value" RefId="12">
<TNRef RefId="3" />
<LST />
</Obj>
</En>
</DCT>
</Obj>
<Nil N="PowerShellGetFormatVersion" />
<Nil N="ReleaseNotes" />
<Obj N="Dependencies" RefId="13">
<TNRef RefId="3" />
<LST />
</Obj>
<S N="RepositorySourceLocation">https://www.powershellgallery.com/api/v2</S>
<S N="Repository">PSGallery</S>
<S N="PackageManagementProvider">NuGet</S>
<Obj N="AdditionalMetadata" RefId="14">
<TN RefId="5">
<T>System.Management.Automation.PSCustomObject</T>
<T>System.Object</T>
</TN>
<MS>
<S N="copyright">(c) 2020 Jan De Dobbeleer. All rights reserved.</S>
<S N="description">A prompt theme engine for any shell</S>
<S N="requireLicenseAcceptance">False</S>
<S N="isLatestVersion">True</S>
<S N="isAbsoluteLatestVersion">True</S>
<S N="versionDownloadCount">186</S>
<S N="downloadCount">1327870</S>
<S N="packageSize">4545</S>
<S N="published">11/29/2021 3:26:02 PM -06:00</S>
<S N="created">11/29/2021 3:26:02 PM -06:00</S>
<S N="lastUpdated">11/29/2021 6:00:34 PM -06:00</S>
<S N="tags">git agnoster theme zsh posh-git prompt paradox robbyrussel oh-my-posh PSModule PSFunction_Set-PoshPrompt PSCommand_Set-PoshPrompt PSIncludes_Function</S>
<S N="developmentDependency">False</S>
<S N="updated">2021-11-29T18:00:34Z</S>
<S N="NormalizedVersion">6.19.0</S>
<S N="Authors">Jan De Dobbeleer</S>
<S N="IsPrerelease">false</S>
<S N="ItemType">Module</S>
<S N="FileList">oh-my-posh.nuspec|oh-my-posh.psm1|oh-my-posh.psd1</S>
<S N="GUID">7d7c4a78-e2fe-4e5f-9510-34ac893e4562</S>
<S N="PowerShellVersion">5.0</S>
<S N="CompanyName">Unknown</S>
</MS>
</Obj>
<S N="InstalledLocation">C:\Program Files\WindowsPowerShell\Modules\oh-my-posh\6.19.0</S>
</MS>
</Obj>
</Objs>
Note that the first file does have all those extra lines at the end, not sure if that might be part of the cause?
6.19.0 is unlisted and 6.19.1 will only support pwsh >= 6 for the time being until I figure this out
@FabianEscarate found it, crashes on PowerShell 5....I'm close to dropping support for that ancient tool...
Oh, where can I find the update for the latest PS versión?:)
It seems the issue comes from sync-poshthemes
. If if comment everything inside the method it downloads the executable(but it's slowwwwwww). It's instant in pwsh core but takes > 1 min in pwsh 5.
removing –PassThru
solves the issue(but themes download creates an empty folder).
@JanDeDobbeleer the answer=> no idea why but if you move -PassThru
before -NewName
it works fine.
Small update, it works fine on PS7, I wasn't aware that there was that update.
I wanted to ask, is there a way to set Oh My Posh on the git bash terminal within Windows?:)
git bash caused lots of headaches in the past but @JanDeDobbeleer will tell you more about it
@FernandoBorea yes, but the you need to add the Powershell oh-my-posh module folder to your PATH on Windows (check what $env:POSH_PATH) says. It actually works, albeit there are some strange things sometimes due to the difference in file system.
I nailed it: the dash you set before passthru is not a dash(https://www.fileformat.info/info/unicode/char/2d/index.htm), it's an en dash(https://www.fileformat.info/info/unicode/char/2013/index.htm)
@lnu that was fricking invisible on first sight 🤷🏻
@JanDeDobbeleer but it works in pwsh core :upside_down_face:
https://github.com/PowerShell/vscode-powershell/issues/1308
Ok so:
https://stackoverflow.com/questions/55049410/powershell-script-runs-when-pasted-into-the-powershell-window-but-not-when-run explanation here:https://docs.microsoft.com/en-us/powershell/scripting/dev-cross-plat/vscode/understanding-file-encoding?view=powershell-7.2#configuring-powershell
find out this extension, looks cool :
Hey!
My apologies for keep bothering, but as @lnu said, I'm having some fun trying to set Bash up. I get this error:
This is my .bashrc:
eval"$(oh-my-posh --init --shell bash --config ~/AppData/Local/Programs/oh-my-posh/themes/powerlevel10k_rainbow.omp.json)"
By the way, I copied the route from the $PROFILE set up for PS7
@FernandoBorea ~
is not pointing to what you think it does. Verify the path 😉
Hey!
I think I still don't find the typo, tried swapping to an absolute path but the same result ocurred:
As you can see, it's pointing to the actual themes directory, but the error persists. The bashrc is now: eval"$(oh-my-posh --init --shell bash --config C:/Users/Ferna/AppData/Local/Programs/oh-my-posh/themes/powerlevel10k_rainbow.omp.json)"
@FernandoBorea The filename path issue between unix and Windows can be complex.
Read: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames .
In general, when you are in Cygwin, always use unix-style path, for example, /something/something. When you need C:/Users/joe/notes.txt, use /cygdrive/c/Users/joe/notes.txt.
When you are in Cygwin terminal, you are running bash. That means, paths like “~” are interpreted by bash first. It also means, backslash means quoting the next char, and double straight quotes quotes your string, just as bash in unix.
Cygwin provides a map from Windows path to unix path, by “mount”. For example, C:/something gets mapped to /cygdrive/c/something.
Not sure what mechanism /cygdrive/c is mapped to the disk. Similarly, how /usr/bin actually refers to the real location repesented by the Windows syntax C:/cygwin/usr/bin. Probably some Cygwin internal.
When in Cygwin, stick with unix style path. When you need C:/something, use /cygdrive/c/something.
Unrelated to Cygwin, but Windows's API actually understand forward slash for path separator, as well as path without a drive letter. It's just that some apps such as cmd.exe doesn't deal with it. Windows PowerShell does. (see Wikipedia's “path” article on this.)
Hey!
I've been trying to set it up for the last few days but I'm still having some issues with Git Bash, perhaps you could point me to where I'm messing up? Tried unix style path but still I get back the same error... Here's my bashrc file, and I even used the same directory to cd into it, which it did without issues, I'm not sure what I'm doing wrong?
EDIT: I tried to run the bashrc command one argument at the time, and it seems the --shell bash argument is what's causing the issue, if I run just that without the path to the actual theme, I still get the error. Perhaps I need o change the Windows style pathing' there, but I'm worried I will mess up the PowerShell side if I do so, and I either way don't know where to find the file that gets executed haha
@FernandoBorea I see there's still some confusion around the Cygwin $HOME
and your Windows $HOME
. You've added the .bashrc
file to your Windows $HOME
where it's not picked up.
on Git BASH this is my .bashrc
which is also inside /c/Users/jan/. bashrc
and works without any issue:
eval "$(oh-my-posh --init --shell bash --config /y/oh-my-posh/themes/blue-owl.omp.json)"
I got extremely frustrated, then tried to set it up on my take-everywhere laptop and worked without any issues at all... I'll probably just delete the bashrc file from my other computer and do it from scratch :) Will keep you posted. Thanks in advance for the tons of help!
As you can see here, I forced to install 6.17 which worked just fine, then I updated to 6.19 and this time it worked too without issues, it just happens when I install 6.19 right away. I show some attempts without admin privileges just in case it helps to narrow something down :) https://www.loom.com/share/c7834f69dbe642f29ee0a967ab87cb6d
I also had to revert to the old version in order to make Powershell actually import oh-my-posh. It still doesn't work though
@SB-USNC please migrate away from the module, it's been deprecated for a while now. You can still use oh-my-posh in PowerShell, follow the guide here.
Try to install oh-my-posh using this command
curl -s https://ohmyposh.dev/install.sh | bash -s
on ubuntu 22.04 and it says
Cannot write to /usr/local/bin. Please run the script with sudo and try again: using sudo curl -s https://ohmyposh.dev/install.sh | bash -s
does not work.
@ai-mine-max that's because you're using sudo on curl
and not bash -s
. So, run curl -s https://ohmyposh.dev/install.sh | sudo bash -s
, if I got that right.
@ai-mine-max that's because you're using sudo on
curl
and notbash -s
. So, runcurl -s https://ohmyposh.dev/install.sh | sudo bash -s
, if I got that right.
Running into the same issue, even when trying the suggestion you mentioned.
These are the two error lines:
chmod: cannot access '/usr/local/bin/oh-my-posh': No such file or directory
main: line 133: oh-my-posh: command not found
@manmartgarc chmod: cannot access '/usr/local/bin/oh-my-posh': No such file or directory
implies it failed to download/extract to that location so I'd expect another error line or output above.
@manmartgarc
chmod: cannot access '/usr/local/bin/oh-my-posh': No such file or directory
implies it failed to download/extract to that location so I'd expect another error line or output above.
Yeah, sorry I just put the two lines in the output that seemed like stderr.
I tried running the installation on a fresh Ubuntu 22.04 install when I got these errors.
I have since gotten rid of Ubuntu and set up Windows 11 with WSL, and had no issues with the installation on both Windows and Ubuntu (WSL).
Sorry I couldn't help more trying to debug the issue on Ubuntu.
@JanDeDobbeleer and @manmartgarc thanks. Seem to work I will look at configs. Using it for the first time.
Just sharing my experience with this today. It might be related. It might not be. I recently switched from Pop_OS to Ubuntu 23.04 and found that I got the same errors reported here. After trying to manually follow through the steps in the script, I found out that the curl that came with Ubuntu snap was not exactly downloading anything within the script. So I uninstalled that and used the apt version. It now works as expected.
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.
Code of Conduct
What happened?
I was trying to install oh-my-posh, succeeded on one computer but for whatever reason, when tried to replicate the process on another computer it failed.
Find here an image about the process I followed:
Theme
Installation Failed
What OS are you seeing the problem on?
Windows
Which shell are you using?
powershell
Log output