Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dumb question; how to install on Windows from the binary release?#4804

Answeredbytertsdiepraam
alshdavid asked this question inQ&A
Discussion options

I have thecoreutils.exe, downloaded from the latest release.

I realize this is a multi-call binary so running.\coreutils.exe ls will runls. Renaming or linkingcoreutils.exe asls.exe will also work.

Right now I am running.\coreutils.exe to print out all the available commands:

pwsh>  .\coreutils.execoreutils 0.0.18 (multi-call binary)Usage: coreutils [function [arguments...]]Currently defined functions:    [, 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

I haven't found an elegant way to parse the currently defined functions so I copy the output of the .\coreutils.exe command and mannually add them to a powershell command that creates links

$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

image

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?

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
3 replies
@alshdavid
Comment options

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 intoC:\Users\my-user\.local and adding them manually to my PATH.

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$HOME/.local

@tertsdiepraam
Comment options

Of course, it's your machine, so do whatever you want! Just make sure to keep things updated for security :)

@alshdavid
Comment options

Good point!

Answer selected byalshdavid
Comment options

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" }
You must be logged in to vote
0 replies
Comment options

@pedroangelini I have updated the script with an auto-download and install script. The script can be used to download and update coreutils.

download-uutils.ps1 --Force --Path "$env:USERPROFILE\local\uutils"$env:Path = "$env:USERPROFILE\local\uutils\bin;$env:Path"Remove-Item Alias:"cat"Remove-Item Alias:"cp"Remove-Item Alias:"dir"Remove-Item Alias:"echo"Remove-Item Alias:"ls"Remove-Item Alias:"mv"Remove-Item Alias:"pwd"Remove-Item Alias:"rm"Remove-Item Alias:"rmdir"
[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"
You must be logged in to vote
1 reply
@krymancer
Comment options

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    }}
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
4 participants
@alshdavid@tertsdiepraam@krymancer@pedroangelini

[8]ページ先頭

©2009-2025 Movatter.jp