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

Invalid download directory for MockTestRunner (EPERM) #1005

Closed
fkpama opened this issue Dec 28, 2023 · 2 comments
Closed

Invalid download directory for MockTestRunner (EPERM) #1005

fkpama opened this issue Dec 28, 2023 · 2 comments

Comments

@fkpama
Copy link

fkpama commented Dec 28, 2023

Please check our current Issues to see if someone already reported this https://github.com/Microsoft/azure-pipelines-task-lib/issues

Environment

azure-pipelines-task-lib version: 4.4.0

Issue Description

When using the lib on a Windows machine and creating an instance of MockTestRunner, the test fail because of access permission when the test is launched from a drive that is not the same as the HOMEDRIVE (i.e: User home at C:\User\foo and test/code launched from F:\Source\Code) if the user doesn't have the necessary permissions on the drive from.

This is because the MockTestRunner instance tries to download the node.exe in the **F:\\**Users\foo since the download directory is inferred from the HOMEPATH environment variable.

The problem is that the HOMEPATH environment variable is defined on Windows to the path of the user home directory without the drive (e.g.: To obtain the complete path you need %HOMEDRIVE%%HOMEPATH%). so the download directory is computed as \User\foo\azure-pipelines-task-lib\...\_downloads, which, when used, is expanded to >>F:\<<User\foo\azure-pipelines-task-lib\...\_downloads and not >>C:\<<User\foo\azure-pipelines-task-lib\...\_downloads

To fix this, I submitted the PR #1006 which replace the order of the checks to test for the USERPROFILE environment variable before HOMEPATH. #On windows machines, the former is defined to the necessary path (C:\Users\foo)

Let me know what I need to provide

Steps to reproduce

  1. Create a Mocha test according to any tutorial . The code of the test MUST be on another drive than the user home drive (%HOMEDRIVE% environment var)
  2. Instanciate MockTestRunner in your test
  3. launch the test from VSCode (confirmed) from the source code directory (not on the same drive as the user home)

Expected behaviour

The MockTestRunner downloads a version of node.exe in the User's home directory

Actual behaviour

The test fails before the users don't have the rights

image

@kirill-ivlev
Copy link
Contributor

Hi @fkpama,
Thank you for providing a fix, we will test/review and merge it.

@fkpama fkpama closed this as completed Jan 4, 2024
@fkpama
Copy link
Author

fkpama commented Jan 4, 2024

Hi @kirill-ivlev,

Thanks

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants