Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poetry env list and other commands do not handle case-insensitive paths as cwd on Windows #3829

Closed
3 tasks done
karrtikr opened this issue Mar 24, 2021 · 3 comments · Fixed by #4813
Closed
3 tasks done
Labels
kind/bug Something isn't working as expected

Comments

@karrtikr
Copy link

karrtikr commented Mar 24, 2021

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

Hi VSCode Python extension dev here 👋 We're planning to support Poetry envs in the extension (microsoft/vscode-python#8372 (comment)).

In order to discover environments, we planned to run poetry env list command. The command works fine in terminal when cwd is in case-exact state.

image

But when drive begins with a lowercase c: instead (which is also a valid path on Windows), things don't seem to work. Every other command other than poetry env list works fine. This can be seen when executed via nodejs.child_process API, it returns empty stdout.

import { exec } from 'child_process';

function shellExecute(command: string, options: ShellOptions = {}): Promise<ExecutionResult<string>> {
    return new Promise((resolve, reject) => {
        const callback = (e: any, stdout: any, stderr: any) => {
            if (e && e !== null) {
                reject(e);
            } else {
                resolve({ stderr: stderr && stderr.length > 0 ? stderr : undefined, stdout });
            }
        };
        exec(command, options, callback); 
    });
}

const result1 = await shellExec('poetry env list', {
    cwd: 'C:\\Users\\karraj\\OneDrive - Microsoft\\Desktop\\folders\\poetry@2-tutorial-project',
});
console.log('poetry env list', result1.stdout);
// Prints:
// poetry env list poetry_2-tutorial-project-6hnqYwvD-py3.7
// poetry_2-tutorial-project-6hnqYwvD-py3.8
// poetry_2-tutorial-project-6hnqYwvD-py3.9

const result2 = await shellExec('poetry env info -p', {
    cwd: 'C:\\Users\\karraj\\OneDrive - Microsoft\\Desktop\\folders\\poetry@2-tutorial-project',
});
console.log('poetry env info', result2.stdout);
// Prints:
// poetry env info C:\Users\karraj\OneDrive - Microsoft\Desktop\folders\poetry@2-tutorial-project\.venv

// Now the drive letter begins with `c:` instead of `C:`.
const result3 = await shellExec('poetry env list', {
    cwd: 'c:\\Users\\karraj\\OneDrive - Microsoft\\Desktop\\folders\\poetry@2-tutorial-project',
});
console.log('poetry env list', result3.stdout);
// Prints:
// poetry env list

const result4 = await shellExec('poetry env info -p', {
    cwd: 'c:\\Users\\karraj\\OneDrive - Microsoft\\Desktop\\folders\\poetry@2-tutorial-project',
});
console.log('poetry env info', result4.stdout);
// Prints:
// poetry env info c:\Users\karraj\OneDrive - Microsoft\Desktop\folders\poetry@2-tutorial-project\.venv
// ^Interesting: drive letter begins with `c:` in the output as well.
@karrtikr karrtikr added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 24, 2021
@karrtikr
Copy link
Author

Actually poetry env info -p also fails in some cases, for eg. if the result is a global environment.

@karrtikr karrtikr changed the title poetry env list does not handle case-insensitive paths as cwd on Windows poetry env list and other commands does not handle case-insensitive paths as cwd on Windows Mar 26, 2021
@karrtikr karrtikr changed the title poetry env list and other commands does not handle case-insensitive paths as cwd on Windows poetry env list and other commands do not handle case-insensitive paths as cwd on Windows Mar 26, 2021
@radoering
Copy link
Member

Probably related to #2419. Thus, may be fixed by #2421 (which has not yet been merged).

@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants