Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-FuzzyGitStatus fails to find the bash.exe path when git is installed globally via scoop #272

Open
kborowinski opened this issue May 17, 2024 · 3 comments

Comments

@kborowinski
Copy link
Contributor

Invoke-FuzzyGItStatus fails to find the bash.exe path when git is installed globally via scoop:

[7.4.2][Bukem@XPS]# $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

[7.4.2][Bukem@XPS]# gmo PSFzf

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.6.1                 PSFzf                               {Enable-PsFzfAliases, Invoke-FuzzyEdit, Invoke-FuzzyFasd, Invoke-FuzzyGitStatus, Invoke-FuzzyHistory, Invoke…

[7.4.2][Bukem@XPS]# gcm git

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     git.exe                                            0.0.0.0    C:\ProgramData\scoop\shims\git.exe

[7.4.2][Bukem@XPS]# gcm scoop

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
ExternalScript  scoop.ps1                                                     C:\Users\Bukem\scoop\shims\scoop.ps1

[7.4.2][Bukem@XPS]# gcm bash

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     bash.exe                                           0.0.0.0    C:\ProgramData\scoop\shims\bash.exe

[7.4.2][Bukem@XPS]# fgs
Resolve-Path: Cannot find path 'C:\PROGRA~3\scoop\bin\bash.exe' because it does not exist.
unknown action: execute-silent("
[7.4.2][Bukem@XPS]# $error|fl * -force

PSMessageDetails      :
Exception             : System.Management.Automation.ItemNotFoundException: Cannot find path 'C:\PROGRA~3\scoop\bin\bash.exe' because it does not exist.
                           at System.Management.Automation.LocationGlobber.ExpandMshGlobPath(String path, Boolean allowNonexistingPaths, PSDriveInfo drive,
                        ContainerCmdletProvider provider, CmdletProviderContext context)
                           at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext context, Boolean allowNonexistingPaths,
                        CmdletProvider& providerInstance)
                           at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext
                        context, CmdletProvider& providerInstance)
                           at System.Management.Automation.PathIntrinsics.GetResolvedPSPathFromPSPath(String path, CmdletProviderContext context)
                           at Microsoft.PowerShell.Commands.ResolvePathCommand.ProcessRecord()
TargetObject          : C:\PROGRA~3\scoop\bin\bash.exe
CategoryInfo          : ObjectNotFound: (C:\PROGRA~3\scoop\bin\bash.exe:String) [Resolve-Path], ItemNotFoundException
FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at SetupGitPaths, C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.6.1\PSFzf.psm1: line 1485
                        at Invoke-PsFzfGitFiles, C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.6.1\PSFzf.psm1: line 1557
                        at Invoke-FuzzyGitStatus, C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.6.1\PSFzf.psm1: line 1347
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}

[7.4.2][Bukem@XPS]#

Global scoop git app folder structure:

[7.4.2][Bukem@XPS]# cd C:\ProgramData\scoop\apps\git
[7.4.2][Bukem@XPS]# dir

        Directory: C:\ProgramData\scoop\apps\git


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2024-05-15 09:06:04                2.45.1
l-r--         2024-05-15 09:06:03                current

[7.4.2][Bukem@XPS]# cd .\current\
[7.4.2][Bukem@XPS]# dir

        Directory: C:\ProgramData\scoop\apps\git\current


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----         2024-05-02 21:06:12                bin
d----         2024-05-15 09:06:02                cmd
d----         2024-05-02 21:06:12                dev
d----         2024-05-15 09:09:06                etc
d----         2024-05-02 21:06:18                mingw64
d----         2024-05-02 21:06:12                tmp
d----         2024-05-02 21:06:03                usr
-a---         2024-05-02 20:44:52         137192 git-bash.exe
-a---         2024-05-02 20:44:52         136680 git-cmd.exe
-a---         2024-05-15 09:06:04           2443 install-context.reg
-a---         2024-05-15 09:06:04           1366 install-file-associations.reg
-a---         2024-05-15 09:06:04             58 install.json
-a---         2024-05-02 21:06:12          18765 LICENSE.txt
-a---         2024-05-15 09:05:47           3167 manifest.json
-a---         2024-05-02 21:06:12           2146 post-install.bat
-a---         2024-05-02 21:06:03           3738 README.portable
-a---         2024-05-15 09:06:04           1393 uninstall-context.reg
-a---         2024-05-15 09:06:04            966 uninstall-file-associations.reg

[7.4.2][Bukem@XPS]# cd bin
[7.4.2][Bukem@XPS]# dir

        Directory: C:\ProgramData\scoop\apps\git\current\bin


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a---         2024-05-02 21:06:12          45560 bash.exe
-a---         2024-05-02 21:06:12          45032 git.exe
-a---         2024-05-02 21:06:12          45560 sh.exe

[7.4.2][Bukem@XPS]#
@kelleyma49
Copy link
Owner

@CeyFun , do you know what would be the fix here as you've made scoop related changes before?

@CeyFun
Copy link
Contributor

CeyFun commented Sep 23, 2024

I don't know what would be the issue. I'll try to reproduce it on my machine when I have some time.

@kborowinski
Copy link
Contributor Author

kborowinski commented Sep 24, 2024

@kelleyma49 @CeyFun:

I think that the issue is here:

    # Detect if git is installed using scoop (using shims)
    if ((Split-Path $gitInfo.Source -Parent) -eq (Split-Path $script:scoopInfo.Source -Parent)) {
        # Get the proper git position relative to scoop shims" position
        $gitInfo = Get-Command "$($gitInfo.Source)\..\..\apps\git\current\bin\git.exe"
    }

When git is installed globally with scoop, then the $gitInfo.Source -Parent and $scoopInfo.Source -Parent will not be the same:

image

If I'm not mistaken, I think that it is enough just to check if $gitInfo.Source -match 'scoop[\\/]shims':

    # Detect if git is installed using scoop (using shims)
    if ($gitInfo.Source -match 'scoop[\\/]shims') {
        # Get the proper git position relative to scoop shims" position
        $gitInfo = Get-Command "$($gitInfo.Source)\..\..\apps\git\current\bin\git.exe"
    }

This fixes the issue when git is installed globally, I didn't check it though, if that works for user scope installation. (it works also with user scope installation of git)

kborowinski added a commit to kborowinski/PSFzf that referenced this issue Sep 25, 2024
kelleyma49 added a commit that referenced this issue Sep 30, 2024
* Fix `Invoke-PsFzfRipgrep` throws `unknown action: change-prompt` after updating to 2.6.1 #273

- Add 'Disabled' param
- Restore unicode icons for git functions and only show in Terminal or non-Windows
- Minor formatting fix

* Fix debug output

* Use fzf directly instead of PowerShell function

* Properly detect if git is installed using scoop regardless of scope (#278)

This fixes the issue #272

---------

Co-authored-by: Kris Borowinski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants