Open kemingy opened 1 year ago
VSCode's rust-analyzer plugin will download binary to it's own dir (by default) and provide a config for users. I think it's also good for envd
.
How to? I read the resolving function and it seems:
$(python3 -m site --user-base)/bin/envd
<intall.path.envdPath>
envd
No .local
things related.
export function getEnvdPath(): string {
const mode = getEnvdLocation();
const pythonPath = getPythonPath();
let path: string | undefined;
switch (mode) {
case EnvdLocation.PIP:
path = getPipEnvdPath(pythonPath);
break;
case EnvdLocation.PATH:
path = getConfig().get<string>('intall.path.envdPath');
break;
default:
warn('invalid config option "undefined" for envd.intall.envdLocation, unable to deduced envd path, fallback to "envd"', Module.CONFIG);
break;
}
if (!path) {
return fallbackEnvdPath;
}
return path;
}
How to? I read the resolving function and it seems:
1. `$(python3 -m site --user-base)/bin/envd` 2. `<intall.path.envdPath>` 3. `envd`
I think it's the 1st one. ~/.local
is used by pip binaries. But I don't have envd
in this directory.
That sounds we should test files existence otherwise keep fallthrough the next branch.
Agree.
I think the 1st one can be type -q envd
to check if we can access it directly.
In Kvrocks, we use which
, while type -q
seems not standrad:
# on macOS (darwin)
$ type -q envd
type: bad option: -q
$ which -a envd
/opt/homebrew/bin/envd
In Kvrocks, we use
which
, whiletype -q
seems not standard:
My bad, type -q
is quite/query (only under fish
shell).
Refer to https://stackoverflow.com/a/677212
Should not use which
. type
should work without the -q
argument. command
and hash
are also suitable.
The config option and UX are actually a bit more subtle. We define envd.intall.envdLocation
to let users specify the location resolution strategy: (so that, it's not quite logically correct to "firstly try type envd
")
switch (mode) {
case 'pip package manager':
return EnvdLocation.PIP;
case 'raw path':
return EnvdLocation.PATH;
default:
warn(`invalid config option "${mode ?? 'undefined'}" for envd.intall.envdLocation, fallback to "pip package manager"`, Module.CONFIG);
return EnvdLocation.PIP;
}
I highly suspect its meaning especially we have intall.path.envdPath
already.
This extension assumes that
envd
should always in~/.local/bin/envd
which may not always be correct.