Skip to content

check nightlies/pr features with etag avalibility#1347

Closed
johnnychen94 wants to merge 1 commit intoJuliaLang:mainfrom
johnnychen94:jc/optional_etag
Closed

check nightlies/pr features with etag avalibility#1347
johnnychen94 wants to merge 1 commit intoJuliaLang:mainfrom
johnnychen94:jc/optional_etag

Conversation

@johnnychen94
Copy link
Member

@johnnychen94 johnnychen94 commented Nov 28, 2025

Users in China often don't have a stable connection to AWS S3, so mirror sites like https://mirrors.tuna.tsinghua.edu.cn exist; they are typically simple static-file HTTP servers and don't have advanced S3-like features such as etags.

Previously, we have provided the JULIAUP_SERVER feature to change the download baseurl, but at that time, I didn't realize that the server mirror should support ETag.

This commit introduces a server feature check operation for custom JULIAUP_SERVER:

  • if JULIAUP_SERVER equals the default official ones, it works as usual. No extra overhead.
  • Otherwise, send a HEAD check request and set the NIGHTLY_SERVER_SUPPORTS_ETAG feature flag

If this feature flag is false, then the PR/nightlies download will be disabled. This doesn't affect the mirror sites because they don't support mirroring Julia nightlies deliberately; too few people use it, and it consumes too much unnecessary sync bandwidth.

Known JuliaUp mirror sites in China that can be used to test:

https://mirrors.ustc.edu.cn/juliaup-releases
https://mirrors.tuna.tsinghua.edu.cn/juliaup-releases https://mirrors.bfsu.edu.cn/juliaup-releases

This commit makes it work for the above mirror sites and thus fixes #917.

Disclaimer: This commit is primarily generated by AI (cursor + claude 4.5 opus). I've tested it locally on Windows and Linux, and it works as expected. MacOS is not tested.

Example: PR/nightlies features are disabled with a proper error message:

❯ target/debug/juliaup add nightly
Error: The configured nightly server does not support etag headers, which are required for nightly and PR channels.
Nightly and PR channels cannot be installed from this server.

❯ target/debug/julia +nightly
Question: The Juliaup channel 'nightly' is not installed. Would you like to install it?: Yes (install this time only)
Installing Julia nightly as requested
Error: The configured nightly server does not support etag headers, which are required for nightly and PR channels.
Nightly and PR channels cannot be installed from this server.
Error: The Julia launcher failed to determine the command for the `nightly` channel.

Caused by:
Failed to install channel 'nightly'. juliaup add command failed with exit code: Some(1)

Example: normal release download just works

❯ target/debug/juliaup add 1.10
Checking for new Julia versions
Installing Julia 1.10.10+0.x64.linux.gnu
DEBUG: Starting download from URL: https://mirrors.ustc.edu.cn/julia-releases/bin/linux/x64/1.10/julia-1.10.10-linux-x86_64.tar.gz
Downloading ━━━━━━━━━━━━━━━━━━━━━━━━╸ 165.61 MiB/165.79 MiB eta: 0s
Add Installed Julia channel '1.10'

closes #917

@johnnychen94 johnnychen94 marked this pull request as draft November 28, 2025 08:54
Users in China often don't have a stable connection to AWS S3, so mirror
sites like https://mirrors.tuna.tsinghua.edu.cn exist; they are
typically simple static-file HTTP servers and don't have advanced
S3-like features such as etags.

Previously, we have provided the JULIAUP_SERVER feature to change the
download baseurl, but at that time, I didn't realize that the server
mirror should support ETag.

This commit introduces a server feature check operation for custom
JULIAUP_SERVER:

* if JULIAUP_SERVER equals the default official ones, it works as usual
* Otherwise, send a HEAD check request and set the
  NIGHTLY_SERVER_SUPPORTS_ETAG feature flag

If this feature flag is false, then the PR/nightlies download will be
disabled. This doesn't affect the mirror sites because they don't
support mirroring Julia nightlies deliberately; too few people use it,
and it consumes too much unnecessary sync bandwidth.

Known JuliaUp mirror sites in China that can be used to test:

https://mirrors.ustc.edu.cn/juliaup-releases
https://mirrors.tuna.tsinghua.edu.cn/juliaup-releases
https://mirrors.bfsu.edu.cn/juliaup-releases

This commit makes it work for the above mirror sites and thus fixes

Disclaimer: This commit is primarily generated by AI (cursor + claude
4.5 opus). I've tested it manually on both Windows and Linux, and it
works as expected.

Example: PR/nightlies features are disabled with a proper error message:

```
❯ target/debug/juliaup add nightly
Error: The configured nightly server does not support etag headers, which are required for nightly and PR channels.
Nightly and PR channels cannot be installed from this server.

❯ target/debug/julia +nightly
Question: The Juliaup channel 'nightly' is not installed. Would you like to install it?: Yes (install this time only)
Installing Julia nightly as requested
Error: The configured nightly server does not support etag headers, which are required for nightly and PR channels.
Nightly and PR channels cannot be installed from this server.
Error: The Julia launcher failed to determine the command for the `nightly` channel.

Caused by:
Failed to install channel 'nightly'. juliaup add command failed with exit code: Some(1)
```

Example: normal release download just works

```
❯ target/debug/juliaup add 1.10
Checking for new Julia versions
Installing Julia 1.10.10+0.x64.linux.gnu
DEBUG: Starting download from URL: https://mirrors.ustc.edu.cn/julia-releases/bin/linux/x64/1.10/julia-1.10.10-linux-x86_64.tar.gz
Downloading ━━━━━━━━━━━━━━━━━━━━━━━━╸ 165.61 MiB/165.79 MiB eta: 0s
Add Installed Julia channel '1.10'
```

closes JuliaLang#917
@johnnychen94 johnnychen94 marked this pull request as ready for review November 28, 2025 09:44
IanButterworth added a commit that referenced this pull request Jan 17, 2026
Fixes critical issues in PR #1347 for better mirror server compatibility:

Critical fixes:
- Add early etag support check in install_from_url BEFORE downloading
  to avoid wasting bandwidth (~165MB) when server doesn't support etags
- Remove redundant etag check after download

Robustness improvements:
- Use proper URL parsing for default server detection instead of string comparison
- Handle URL variations (http/https, trailing slashes) correctly
- Remove unwrap() from Windows HEAD request that could panic
- Add debug logging for all error paths in server capability checks

These changes prevent users from downloading large tarballs only to get
an error, and make the server capability detection more reliable across
different mirror configurations.
@IanButterworth
Copy link
Member

Thanks @johnnychen94

I had some suggestions on top of this, and it had some conflicts that were easier to deal with in a new PR #1387

See c36a95e (#1387) for the tweaks.

I'll go ahead with that PR. Thanks!

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.

custom JULIAUP_SERVER for normal http server

2 participants