broot
broot copied to clipboard
`br` command fails on Windows
After installing broot
using scoop and executing broot --install
to be able to use the br
command, I'm met with an error.
> br
File not found: "C:\\Users\\Username\\AppData\\Local\\Temp\\tmpC170.tmp"
I think it's because my username has a space in it, as it duplicated the second word in my username. I looked at the modified $PROFILE
, and I'm not sure what's wrong with the br
function, though I'm not versed in .ps1
syntax.
Is that the exact error message ? With "Username" ?
No, changed it since it contained my actual name.
It should look more something like this.
> br
File not found: "C:\\Users\\Name Surname\\Surname\\AppData\\Local\\Temp\\tmpC170.tmp"
It repeated the username after the first space.
The problem is probably in the way the shell script gives the path to broot but I don't know powershell well enough and I don't have any Windows box available so I need somebody else to try fix the script.
https://github.com/Canop/broot/blob/4856d360c83ca0ac6a341afa577ec3e875de113c/src/shell_install/powershell.rs#L29C1-L29C1
Modify $($cmd_file.FullName)
to
`"$($cmd_file.FullName)`"
maybe work
I tried to reproduce this by creating a test user but can't even complete the br
function install prerequisite. I wonder what should I do besides having a space in username?
Steps:
- Create a local user account
- Deliberately input the user name "test use"
- Install broot and try to install
br
function withsudo broot --install
PS C:\Users\test use> sudo broot --install
You requested a clean (re)install.
Removing C:\Users\test use\AppData\Roaming\dystroy\broot\data\launcher\bash\1.
Writing br shell function in C:\Users\test use\AppData\Roaming\dystroy\broot\data\launcher\bash\1.
Removing C:\Users\test use\AppData\Roaming\dystroy\broot\config\launcher\bash\br.
Creating link from C:\Users\test use\AppData\Roaming\dystroy\broot\config\launcher\bash\br to C:\Users\test use\AppData\Roaming\dystroy\broot\data\launcher\bash\1.
I found no sourcing file for the bash/zsh family.
If you're using bash or zsh, then installation isn't complete:
the br function initialization script won't be sourced unless you source it yourself.
PS C:\Users\test use>
P.S. The "I found no sourcing file for the bash/zsh family." warning is not problematic because the same happened to my real account but completed the br
function installation onward in PowerShell.
can you try the product compiled on my local machine?
- Remove the original broot
- Add the newly downloaded broot.exe path to env path
-
broot --install
- Open new powershell window and run
br
can you try the product compiled on my local machine?
1. Remove the original broot 2. Add the newly downloaded broot.exe path to env path 3. `broot --install` 4. Open new powershell window and run `br`
Thank you for notice! The broot --install
result is the same...
PS C:\Users\test use> broot --version
broot 1.27.1-dev
PS C:\Users\test use> br
br : The term 'br' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ br
+ ~~
+ CategoryInfo : ObjectNotFound: (br:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
@Elkiwa
You can check whether these two files exist and whether their contents are normal
-
C:\Users{username}\AppData\Roaming\dystroy\broot\config\launcher\powershell\br.ps1
-
C:\Users{username}\Documents\WindowsPowerShell\Profile.ps1
in my windows powershell
PS C:\Users\zzz> broot --install
You requested a clean (re)install.
Removing C:\Users\zzz\AppData\Roaming\dystroy\broot\config\launcher\installed-v4.
Removing C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\bash\1.
Writing br shell function in C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\bash\1.
Removing C:\Users\zzz\AppData\Roaming\dystroy\broot\config\launcher\bash\br.
Creating link from C:\Users\zzz\AppData\Roaming\dystroy\broot\config\launcher\bash\br to C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\bash\1.
I found no sourcing file for the bash/zsh family.
If you're using bash or zsh, then installation isn't complete:
the br function initialization script won't be sourced unless you source it
yourself.
Removing C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\nushell\4.
Writing br shell function in C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\nushell\4.
Removing C:\Users\zzz\AppData\Roaming\dystroy\broot\config\launcher\nushell\br.
Creating link from C:\Users\zzz\AppData\Roaming\dystroy\broot\config\launcher\nushell\br to C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\nushell\4.
C:\Users\zzz\AppData\Roaming\nushell\config.nu already patched, no change made.
Removing C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\powershell\1.
Writing br shell function in C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\powershell\1.
Removing C:\Users\zzz\AppData\Roaming\dystroy\broot\config\launcher\powershell\br.ps1.
Creating link from C:\Users\zzz\AppData\Roaming\dystroy\broot\config\launcher\powershell\br.ps1 to C:\Users\zzz\AppData\Roaming\dystroy\broot\data\launcher\powershell\1.
C:\Users\zzz\Documents\WindowsPowerShell\Profile.ps1 already patched, no change made.
The br function has been successfully installed.
You may have to restart your shell or source your shell init files.
Afterwards, you should start broot with br in order to use its full power.
but I guess you are probably using powershell core (aka. pwsh or PowerShell 7.x, cross platform)
Instead of Windows powershell (aka. PowerShell 5.1, windows built-in), broot --install
does not yet support pwsh
You can try it using windows powershell
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.3
@Elkiwa
You can check whether these two files exist and whether their contents are normal
* C:\Users{username}\AppData\Roaming\dystroy\broot\config\launcher\powershell\br.ps1 * C:\Users{username}\Documents\WindowsPowerShell\Profile.ps1
Thank you. I'll try looking into it, though I'm not that familiar with PowerShell syntax.
but I guess you are probably using powershell core (aka. pwsh or PowerShell 7.x, cross platform) Instead of Windows powershell (aka. PowerShell 5.1, windows built-in),
broot --install
does not yet support pwsh You can try it using windows powershellhttps://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.3
Actually, I've already aware the difference of PowerShell and pwsh. All the above experiments are performed in PowerShell. My real Windows user account has br
function installed in PowerShell, but I use pwsh whenever possible.
@Elkiwa
If those two files are not generated, you can obtain the log file in the current directory by following the steps below:
-
$env:BROOT_LOG='debug' ; broot --install
-
cat broot.log
https://dystroy.org/broot/community/#log
@lost22git Here comes the result.
PS C:\Users\test use> cat broot.log
00:55:56.454 [INFO] cli_log::init: Starting broot v1.27.1-dev with log level DEBUG
00:55:56.454 [DEBUG] broot: env::args(): [
"C:\\Users\\test use\\broot\\broot.exe",
"--install",
]
00:55:56.457 [INFO] broot::shell_install: Shell installation state: NotInstalled
00:55:56.457 [DEBUG] broot::shell_install: Starting install
00:55:56.457 [INFO] broot::shell_install: Writing `br` shell function in `"C:\\Users\\test use\\AppData\\Roaming\\dystroy\\broot\\data\\launcher\\bash\\1"`
00:55:56.458 [INFO] broot::shell_install: Creating link from "C:\\Users\\test use\\AppData\\Roaming\\dystroy\\broot\\config\\launcher\\bash\\br" to "C:\\Users\\test use\\AppData\\Roaming\\dystroy\\broot\\data\\launcher\\bash\\1"
00:55:56.461 [DEBUG] broot::shell_install::bash: considering path: "C:\\Users\\{real user}\\.bashrc"
00:55:56.461 [DEBUG] broot::shell_install::bash: considering path: "C:\\Users\\{real user}\\.bash_profile"
00:55:56.462 [DEBUG] broot::shell_install::bash: considering path: "C:\\Users\\{real user}\\.zshrc"
00:55:56.462 [DEBUG] broot::shell_install::bash: considering path: "C:\\Users\\{real user}\\$ZDOTDIR/.zshrc/.zshrc"
00:55:56.462 [WARN] broot::shell_install::bash: no sourcing path for bash/zsh!
00:55:56.462 [DEBUG] broot::shell_install::fish: no fish config directory. Assuming fish isn't used.
00:55:56.462 [INFO] broot::shell_install::nushell: install nushell
00:55:56.462 [DEBUG] broot::shell_install::nushell: no nushell config directory. Assuming nushell isn't used.
00:55:56.462 [INFO] broot::shell_install::powershell: install powershell
00:55:56.462 [WARN] broot::shell_install::powershell: Could not find user documents directory.
00:55:56.462 [INFO] broot: bye
PS C:\Users\test use> [Environment]::GetFolderPath("MyDocuments")
C:\Users\test use\Documents
PS C:\Users\test use> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Could you verify my result?
https://github.com/Canop/broot/blob/996b34fb5cb2dfafe87269ee97b895b4e09bf937/src/shell_install/powershell.rs#L80C1-L80C1
Looks like a third-party library directories-rs issue
I upgraded broot's directories-rs to the latest version. This is the new compiled product. you can try it
@lost22git I can't test on Windows. What you're saying is the problem should be fixed with the last version of directories-rs ?
@Canop I'm not sure if directories-rs has fixed this problem
I upgraded broot's directories-rs to the latest version. This is the new compiled product. you can try it
@lost22git Unfortunately, nothing changed in the debug log, but I can reason with you. I read some docs from directories-rs
and the spec from Microsoft, but still can't tell where the issue could be.
I'm not sure if it's directly involved with this issue, but username with more than one space causes errors in installation.
@2gn This is specific and looks actionable. Can you create a separate issue for that ?
https://github.com/Canop/broot/blob/4856d360c83ca0ac6a341afa577ec3e875de113c/src/shell_install/powershell.rs#L29C1-L29C1
Modify
$($cmd_file.FullName)
to`"$($cmd_file.FullName)`"
maybe work
I was having the same issue:
File not found: "C:\\Users\\Rafael Dominiquini\\Dominiquini\\AppData\\Local\\Temp\\tmpudrel1.tmp"
But this suggestion (https://github.com/Canop/broot/issues/788#issuecomment-1807002078) solve it!
Thanks.
Looks like this is the same problem mentioned in #849 The solution does seem to be as simple as adding the escape characters, but I also removed the subshell syntax.
Test this br.ps1 for me
Function br {
$args = $args -join ' '
$cmd_file = New-TemporaryFile
$out_file = New-TemporaryFile
$process = Start-Process -FilePath 'broot.exe' `
-ArgumentList "--outcmd `"$cmd_file`" $args" `
-NoNewWindow -PassThru -WorkingDirectory $PWD `
-RedirectStandardOutput $out_file
Wait-Process -InputObject $process # Faster than Start-Process -Wait
Get-Content $out_file # print broot's stdout to shell stdout
If ($process.ExitCode -eq 0) {
$cmd = Get-Content $cmd_file
Remove-Item $cmd_file, $out_file
If ($cmd -ne $null) { Invoke-Expression -Command $cmd }
} Else {
Remove-Item $cmd_file, $out_file
Write-Host "`n" # Newline to tidy up broot unexpected termination
Write-Error "broot.exe exited with error code $($process.ExitCode)"
}
}