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

Set tool(-bin) dir and add to PATH #87

Merged
merged 3 commits into from
Sep 21, 2024
Merged

Set tool(-bin) dir and add to PATH #87

merged 3 commits into from
Sep 21, 2024

Conversation

eifinger
Copy link
Collaborator

@eifinger eifinger commented Sep 18, 2024

Fixes: #83
Fixes: #60

@eifinger
Copy link
Collaborator Author

@charliermarsh I still get the warning described in #60 as can be seen here: https://github.com/astral-sh/setup-uv/actions/runs/10925849201/job/30328341490?pr=87#step:4:10

Could the reason be that uv.exe gets installed into C:\hostedtoolcache\windows\uv\0.4.12\x86_64 which is on the C: drive while UV_CACHE_DIR and UV_TOOL_BIN_DIR is on the D: drive?

@eifinger
Copy link
Collaborator Author

@charliermarsh I still get the warning described in #60 as can be seen here: https://github.com/astral-sh/setup-uv/actions/runs/10925849201/job/30328341490?pr=87#step:4:10

Could the reason be that uv.exe gets installed into C:\hostedtoolcache\windows\uv\0.4.12\x86_64 which is on the C: drive while UV_CACHE_DIR and UV_TOOL_BIN_DIR is on the D: drive?

Okay even when uv.exe in on the D: drive this warning appears: https://github.com/astral-sh/setup-uv/actions/runs/10928325743/job/30336478681?pr=89

@eifinger
Copy link
Collaborator Author

@charliermarsh I still get the warning described in #60 as can be seen here: https://github.com/astral-sh/setup-uv/actions/runs/10925849201/job/30328341490?pr=87#step:4:10
Could the reason be that uv.exe gets installed into C:\hostedtoolcache\windows\uv\0.4.12\x86_64 which is on the C: drive while UV_CACHE_DIR and UV_TOOL_BIN_DIR is on the D: drive?

Okay even when uv.exe in on the D: drive this warning appears: https://github.com/astral-sh/setup-uv/actions/runs/10928325743/job/30336478681?pr=89

The reason was that UV_TOOL_DIR was still on C:

@eifinger eifinger force-pushed the windows-tools-path branch 2 times, most recently from dd940eb to 3f421bc Compare September 18, 2024 19:32
@eifinger eifinger marked this pull request as ready for review September 18, 2024 19:35
Make sure the default tool bin dir or the user supplied is added to the PATH.
On Windows the tool dir and tool bin dir is moved to the TMP dir to take advantage of the fact that on GitHub hosted Windows runners this is on the faster D: drive
@eifinger eifinger changed the title Add tool bin dir to PATH Set tool(-bin) dir and add to PATH Sep 18, 2024
- name: Install the latest version of uv with a custom tool dir
uses: astral-sh/setup-uv@v3
with:
tool-dir: "/path/to/tool/dir"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not just be done via env:?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user would have to add this to every step using uv then. That's why I decided against it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, smart

### UV_TOOL_DIR

On Windows `UV_TOOL_DIR` is set to `uv-tool-dir` in the `TMP` dir (e.g. `D:\a\_temp\uv-tool-dir`).
On GitHub hosted runners this is on the much faster `D:` drive.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the cache is also on the D: drive, is that right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's also in the TMP dir so D:\a\_temp\ on Windows

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added documentation for the default value of UV_CACHE_DIR

return toolBinDirInput;
}
if (process.platform === "win32") {
return "D:\\a\\_temp\\uv-tool-bin-dir";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs said it's on D: on GitHub-hosted runners. But isn't this setting it on all runners? Is that ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I should rather implement it like the cache, look for RUNNER_TEMP first and only use a static value as fallback.

On second thought maybe even fail if RUNNER_TEMP is not set. The static fallback path (and drive) might not even exist and then fail with hard to understand error messages

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to throw if RUNNER_TEMP is not set.

return `${process.env.RUNNER_TEMP}${path.sep}uv-tool-bin-dir`;
}
throw Error(
"Could not determine UV_TOOL_BIN_DIR. Please make sure RUNNER_TEMP is set or provide the tool-bin-dir input",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it that RUNNER_TEMP is always defined on GitHub runners?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So tests show that it is and I could not find contrary information

@eifinger eifinger merged commit aeb4649 into main Sep 21, 2024
56 checks passed
@eifinger eifinger deleted the windows-tools-path branch September 21, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support uv tool install on Windows Cache fails for Windows fallback to copy
3 participants