elves / elvish

Powerful scripting language & versatile interactive shell

Home Page:https://elv.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

epm module does not work in Windows

iandol opened this issue · comments

I needed to use a Windows 11 machine, and tried to get elvish to use my rc.elv. I find that with standard commands to conditionally install:

epm:install &silent-if-installed ^
	github.com/iwoloschin/elvish-packages ^
	github.com/zzamboni/elvish-modules ^
	github.com/muesli/elvish-libs ^
	github.com/xiaq/edit.elv

I get an error:

=> Installing github.com/iwoloschin/elvish-packages
fatal: destination path 'C:\Users\iando\AppData\Local/elvish/lib/github.com/iwoloschin/elvish-packages' already exists and is not an empty directory.

On inspection by @krader1961, it appears there are several places where the epm module uses *nix commands like test, e.g.

# Returns a boolean value indicating whether the given package is installed.
fn is-installed {|pkg|
  bool ?(test -e (dest $pkg))
}

It would be great if epm could be updated to try to remove some of these *nix-only dependencies if possible...

On line 29 of epm.elv %appdata% is hard-coded for Windows, it would be nice if we could check for XDG_ env variables first...

Note that resolving issue #1659 would make it possible for the epm module to only rely on commands (like rsync and git) that will never be be integrated as an Elvish builtin. Thus making it simpler to document the explicit external commands the epm module depends on.

The hardcoded %appdata% value could be replaced with a dynamic value if issue #1600 is resolved.

As things stand today, a user needs to install the MSYS2 package to be able to use the epm module on Windows. While installing MSYS2 is a good idea for anyone expecting a CLI experience on Windows comparable to a UNIX system it shouldn't be mandatory for using the epm module. It should be sufficient for the user to have installed the handful of commands (e.g., curl) that cannot be reasonably expected to be Elvish builtins.

The hardcoded %appdata% value could be replaced with a dynamic value if issue #1600 is resolved.

It seems that just got fixed, so one step closer...

@iandol, I don't see any commits that resolve issue #1600 and that issue is still open. Can you provide a Git commit ID? I'm guessing you misunderstood the point of an unrelated change but I would be thrilled to learn I am wrong.

@krader1961 -- indeed my mistake, I read #1660 and missed the second 6 — sorry for the false hope!!!

FWIW, with the changes I have queued the epm module will only depend on the rsync and git external commands. That is still a bit of a challenge for its use by Elvish users on Windows but it is at least easier, in theory, to document how to satisfy the requirement for those two commands without requiring the user to install Msys2 or something similar. It is not obvious how to eliminate the requirement to have the rsync and git external commands available on Windows but at least the changes I have queued limit the external command dependencies to those two commands.

Dear Kurtis, thank you for you work on this. AFAIK there are native versions of both rsync and git (at least available via scoop), so this should be better than the full msys2 requirement.