Skip to content

Conversation

@Inasayang
Copy link

support custom app data dir via ANYZIG_DATA_DIR env var

  • Check ANYZIG_DATA_DIR environment variable first
  • Fallback to std.fs.getAppDataDir if env var not set

@marler8997
Copy link
Owner

what's the use case for this? I would like to add this feature for testing, though I was thinking it would probably be a command-line option.

@Inasayang
Copy link
Author

what's the use case for this? I would like to add this feature for testing, though I was thinking it would probably be a command-line option.

On Windows, Zig is installed on the C drive by default, but some people like me who have OCD tendencies prefer to install it on other drives, such as the D drive. Just like with rustup, setting RUSTUP_HOME and CARGO_HOME environment variables allows you to avoid installing to the C drive.

@marler8997
Copy link
Owner

Hmmm...at least right now, this would only affect where anyzig installs the configuration and some cached data, it wouldn't affect where the compilers are installed. Is this still a configuration you'd find helpful, having a way to modify where anyzig stores some of it's configuration and/or cached files?

@Inasayang
Copy link
Author

Inasayang commented Jul 15, 2025

Hmmm...at least right now, this would only affect where anyzig installs the configuration and some cached data, it wouldn't affect where the compilers are installed. Is this still a configuration you'd find helpful, having a way to modify where anyzig stores some of it's configuration and/or cached files?

e371c52 This commit only changes the hashstore directory of anyzig. So this commit has no practical value.🥲😭
6b7e484 This commit changes zig's cache_dir to use ANYZIG_DATA_DIR/zig when ANYZIG_DATA_DIR is available, otherwise defaults to the standard behavior.

As for the configuration file, storing it in %USERPROFILE%\.anyzig or %USERPROFILE%\anyzig\config or $HOME\.anyzig or $HOME\anyzig\config would be fine. It won't take up much storage space.

@marler8997
Copy link
Owner

Yes I can see how changing the global cache dir would be useful. I'm not sure an environment variable is the right choice here though? What about a configuration file, basically the same thing I did for the logging configuration. anyzig can check if "appdata/global-cache-dir" exists and if so, it reads it and uses that for the global cache directory.

@Inasayang
Copy link
Author

Yes I can see how changing the global cache dir would be useful. I'm not sure an environment variable is the right choice here though? What about a configuration file, basically the same thing I did for the logging configuration. anyzig can check if "appdata/global-cache-dir" exists and if so, it reads it and uses that for the global cache directory.

I believe the appdata directory is determined only after the first use.

The configuration file can be used to decide the default Zig version, or specify particular Zig versions for specific projects, or set mirror addresses, etc.

Moreover, during the first use, there's only one executable file called anyzig, and the configuration file is generated after the first execution.

Just like rustup - it installs Rust to RUSTUP_HOME and simultaneously creates settings.toml in the .rustup directory.

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.

2 participants