Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.7k
Dumb question; how to install on Windows from the binary release?#4804
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I have the I realize this is a multi-call binary so running Right now I am running I haven't found an elegant way to parse the currently defined functions so I copy the output of the $utils="arch","b2sum","b3sum","base32","base64","basename","basenc","cat","cksum","comm","cp","csplit","cut","date","dd","df","dir","dircolors","dirname","du","echo","env","expand","expr","factor","false","fmt","fold","hashsum","head","hostname","join","link","ln","ls","md5sum","mkdir","mktemp","more","mv","nl","nproc","numfmt","od","paste","pr","printenv","printf","ptx","pwd","readlink","realpath","relpath","rm","rmdir","seq","sha1sum","sha224sum","sha256sum","sha3-224sum","sha3-256sum","sha3-384sum","sha3-","512sum","sha384sum","sha3sum","sha512sum","shake128sum","shake256sum","shred","shuf","sleep","sort","split","sum","sync","tac","tail","tee","test","touch","tr","true","truncate","tsort","uname","unexpand","uniq","unlink","vdir","wc","whoami","yes"Foreach ($utilin$utils) {$util_path= (-join(".\",$util,".exe"))New-Item-ItemType SymbolicLink-Path$util_path-Target".\coreutils.exe" } Which gives me the utils as symlinks in a directory that I add to my $PATH variable But I can't help but feel this isn't how we should be installing the utils. How do you do it? How are you supposed to do it? |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
The symlinks and adding the directory sounds about right actually if you do it manually. Generally, we recommend using a package manager though. On Windows, you can usescoop for example, which should do all of that for you. At some point we had contributors working on packaging uutils for the Windows store as well, but I think that work has stalled for now.
Replies: 3 comments 4 replies
-
The symlinks and adding the directory sounds about right actually if you do it manually. Generally, we recommend using a package manager though. On Windows, you can use |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I know it's blasphemy but I generally avoid package managers on Windows unless absolutely necessary. I inevitably run into issues with permissions, install locations, config locations, WSL, how is it added to the PATH, is it installed to Program Files? Program Data? LocalRoaming? Documents? Or whatever the MS store does? I've reverted to simply putting binaries into It's embarrassing boring but there's no ambiguity about where something is, what configuration it has or how to uninstall it. It's saved so many headaches EDIT: same goes for MacOS to a lesser extent. I only use brew when Ihave to, otherwise I just put binaries in |
BetaWas this translation helpful?Give feedback.
All reactions
-
Of course, it's your machine, so do whatever you want! Just make sure to keep things updated for security :) |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1🚀 1
-
Good point! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi! Thanks for this question / anwer@alshdavid and@tertsdiepraam -- that was exactly what I was trying to do. For anyone as lazy as me thinking "I don't want to go over the list of utils, just get all of them", the below script will create links to all of them without explicitly listing which ones you want. In my machine it requires opening Powershell as admin (not completely sure why). # based on this question: https://github.com/uutils/coreutils/discussions/4804[CmdletBinding()]param()$utilsList=@(coreutils.exe--list)Foreach ($utilin$utilsList) {$util_path= (-join (".\",$util,".exe"))Write-Verbose-Message"Creating link to$util as$util_path"New-Item-ItemType SymbolicLink-Path$util_path-Target".\coreutils.exe" } |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 3
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@pedroangelini I have updated the script with an auto-download and install script. The script can be used to download and update coreutils. [CmdletBinding()]param ($path, [switch]$force)$dir_target=$pathif ("$dir_target"-eq"") {$dir_target="$env:USERPROFILE\local\uutils"}Write-Host"TARTGET DIR:$dir_target"Write-Host"OS:$([System.Runtime.InteropServices.RuntimeInformation]::OSDescription)"$platform=switch-Wildcard ([System.Runtime.InteropServices.RuntimeInformation]::OSDescription) {"*Windows*" {"pc-windows-msvc.zip" }"*Linux*" {"unknown-linux-musl.tar.gz" }"*Darwin*" {"apple-darwin.tar.gz" }Default {exit1 }}Write-Host"CPU:$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)"$arch=switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) {"X64" {"x86_64" }"X86" {"i686" }"Arm" {"arm" }"Arm64" {"aarch64" }Default {Write-Host"Unknown CPU architecture"exit1 }}$url_api="https://api.github.com/repos/uutils/coreutils/releases/latest"Write-Host"URL GitHub:$url_api"$response=Invoke-WebRequest-Uri"$url_api"-UseBasicParsing$releases=$response|ConvertFrom-Json$url_target=""$name_target=""foreach ($assetin$releases.assets) {if ($asset.browser_download_url.Contains("$arch-$platform")) {$url_target=$asset.browser_download_url$name_target=$asset.name }}Write-Host"URL Archive:$url_target"if ($force) {Write-Host"ACTION: Deleting & recreating`"$dir_target`""}else {Write-Host-ForegroundColor red-NoNewLine"PROMPT: Delete & recreate`"$dir_target`" [y/n]"$confirmation=Read-Hostif ($confirmation-ne'y') {exit0 }}if (Test-Path"$dir_target" ) {Remove-Item-Force-Recurse$dir_target|Out-Null}New-Item-ItemType Directory-Force-Path$dir_target|Out-Null$path_temp="$dir_target\.temp"$path_archive="$path_temp\$name_target"$name_stripped="$([io.path]::GetFileNameWithoutExtension("$name_target"))"if (Test-Path"$path_temp" ) {Remove-Item-Recurse-Force"$path_temp"|Out-Null}New-Item-ItemType Directory-Force-Path$path_temp|Out-NullWrite-Host"ACTION: Downloading archive"Invoke-WebRequest$url_target-OutFile"$path_archive"Write-Host"ACTION: Expanding archive"switch-wildcard ($url_target){"*.zip" {Expand-Archive"$path_archive"-DestinationPath"$path_temp"|Out-NullGet-ChildItem-Path"$path_temp\$name_stripped"-Recurse|Move-Item-Destination"$dir_target" }"*.tar.gz" { echo"tar.gz" }"*.tar.xz" { echo"tar.xz" }Default {Write-Host"Unknown archive kind:$url_target"exit1 }}$bin_dir="$dir_target\bin"if (Test-Path"$bin_dir" ) {Remove-Item-Recurse-Force"$bin_dir"|Out-Null}New-Item-ItemType"directory""$bin_dir"|Out-NullNew-Item-ItemType SymbolicLink-Path"$bin_dir\coreutils.exe"-Target"$dir_target\coreutils.exe"|Out-Null$existing_aliases=""functionCheck-Command($cmdname){return [bool](Get-Command-Name$cmdname-ErrorAction SilentlyContinue)}Foreach ($utilin@(."$bin_dir\coreutils.exe"--list)) {$target_path="$bin_dir\$util.exe"$coreutils="$dir_target\coreutils.exe"Write-Host-Message"LINK:$coreutils ->$target_path"New-Item-ItemType SymbolicLink-Path"$target_path"-Target"$coreutils"|Out-Nullif ("$util"-eq"[") {continue }if (Check-Command$util) {if ("$((Get-Command"$util").CommandType)"-eq"Alias") {$existing_aliases+="Remove-Item Alias:`"$util`"`r`n" } }}if (Test-Path"$path_temp" ) {Remove-Item-Recurse-Force"$path_temp"|Out-Null}Write-Host""Write-Host"Add this to`$profile:"Write-Host""Write-Host"Remove-Item Alias:`"cat`""Write-Host"Remove-Item Alias:`"cp`""Write-Host"Remove-Item Alias:`"dir`""Write-Host"Remove-Item Alias:`"echo`""Write-Host"Remove-Item Alias:`"ls`""Write-Host"Remove-Item Alias:`"mv`""Write-Host"Remove-Item Alias:`"pwd`""Write-Host"Remove-Item Alias:`"rm`""Write-Host"Remove-Item Alias:`"rmdir`""Write-Host""Write-Host"Add this directory to your`$PATH:"Write-Host""Write-Host"$dir_target\bin" |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
-
I am using something similar: # https://github.com/uutils/coreutils# add "aliases" (powershell functions in this case)# to each avaliable tool in coreutils --list# I use an list to exclude commands so I can use# other programs in place for some utils$excluded_commands=@("ls",# Use eza"cat",# Use bat"cd"# Use zoxide)$all_commands= (coreutils--list)-replace'\[|\]'-split"`n"|Where-Object {$_-match'\w+' }|ForEach-Object {$_.Trim() }foreach ($commandin$all_commands) {if ($excluded_commands-notcontains$command) {$function_definition="function$command { & coreutils.exe$command`$args}"Invoke-Expression$function_definition }} |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 2
