tensorchord / vscode-envd

vscode extension for envd
https://marketplace.visualstudio.com/items?itemName=tensorchord.vscode-envd
Apache License 2.0
2 stars 4 forks source link

bug: `~/.local/bin/envd` no such file or directory #25

Open kemingy opened 1 year ago

kemingy commented 1 year ago

This extension assumes that envd should always in ~/.local/bin/envd which may not always be correct.

Xuanwo commented 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.

tisonkun commented 1 year ago

How to? I read the resolving function and it seems:

  1. $(python3 -m site --user-base)/bin/envd
  2. <intall.path.envdPath>
  3. 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;
}
kemingy commented 1 year ago

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.

tisonkun commented 1 year ago

That sounds we should test files existence otherwise keep fallthrough the next branch.

kemingy commented 1 year ago

Agree.

I think the 1st one can be type -q envd to check if we can access it directly.

tisonkun commented 1 year ago

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
kemingy commented 1 year ago

In Kvrocks, we use which, while type -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.

tisonkun commented 1 year ago

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.