-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
zig runtime configuration options: zig config
and how it relates to zig-cache location
#2170
Comments
Interesting idea! It looks like there are actually multiple proposals here:
One note about the example:
zig fmt won't be configurable (needs to be added to a FAQ). And I'm not sure what silencing errors would do in this case; zig fmt should either succeed or fail. I have a couple issues with the idea in general:
Your analogy is |
yes! Zig is fairly sophisticated and I agree that over-configuration is something to be avoided. That said, zig-cache is a perfect example of something that is tough to decide where it goes but I know it doesn't go where I want it to go today. One of the last places I wanted it to go was actually hidden away like Xcode.app does in some application support folder. And yet there it was. I almost always want my build output, including caches, to go in a build directory even if it means copies of cache entries. And putting it in $PWD/zig-cache is convenient but probably a bit extreme for my preference. Very subjective stuff. A very common course of evolution in software is to keep adding ENV options for configuration. ENV has its place but can get unwieldy very quickly. Is Zig going to have a
not suggesting we add those features. but they did come to mind because right now (or it did a week ago)
I like this too. If it can be made to work like that excellent. I only want config options when they have enough need-pressure and are not over-engineered. Sorry if some of my examples appeared over-engineered; but I don't want that to detract from the main prediction that there are going to be a number of configuration options and we should deeply consider
I cannot think of any programming language compiler that take a related to |
Some notes about zig-cache: There are 2 zig-cache directories. One is project-local. One is global. The global one makes sense to be global because it has builtin.a, compiler-rt.a, musl libc.a, builtin.zig, etc, built from source lazily for the target, and will be shared by the same zig compiler version for all projects. It saves a lot of accumulated time. The project-local one is by default in the same directory as build.zig, in the root of the project directory. It uses the same caching system but has project-local artifacts in it. The project-local directory is also available for general use by users as a sort of "scratch directory" as long as the caching system files are not disturbed. Zig does not use any system temporary directories, and I don't think there is any reason to.
I don't agree with either of these statements. Can you point to any specific file on your file system (inside one of the zig-cache folders) and tell me why it doesn't belong there? Has the caching system caused a specific problem for you? |
@mikdusan Awesome, thanks for the thoughtful reply. I think what would be helpful for me is if this were split into two separate proposals: a) a zig cache config proposal, and b) a config system/tool proposal for the long term, each with its own justification / use case / problem demonstration. I think they're truly unrelated issues.
Agreed that should be avoided! But the thing is that there currently aren't any environment variables or conf files, so I have a hard time worrying about an overabundance. :> |
This works: // zig fmt: off
test "this is left alone" { }
// zig fmt: on This is undocumented though, so I'm not surprised you missed this. See #1523. |
that is really cool. I'll have to think hard on how that impacts what I'm proposing for
What about non-
I would like for zig to infer work-tree and use today these are a few cases showing creates
|
closing this issue as it seems like a solution for a non-existing problem. thank you everyone for taking the time to reply. |
@mikdusan, I really like nim's way to handle configuration via |
@timotheecour You can pass |
that's what I was afraid of, can we re-open this feature request? like I said, nim has |
long term proposal
Once Zig is installed, a user will need various configuration options. Think
git config
-like ability. This will define consistent and flexible behaviour forzig-cache
directory location.Currently
zig-cache
is located in one of:Propose that we steer Zig in direction of familiar configuration mechanism of
git config
. Location options forzig-cache
can be:dir
→ example:/tank01/zig-cache
pwd
→ example:$PWD/zig-cache
tmp
→ example:/var/folders/xp/s2xy5w692315r6rmm8_30v3m0000gp/T/zig-cache
local
→ example:/User/mike/project/.zig/cache
global
→ example:/User/mike/Library/Application Support/Zig/cache
here is a sample of what kinds of things could be configured:
note: any child zig executions launched in a different pwd wishing to use the same work-tree would be launched with
--work-tree
The following are configuration-points selected with
zig config
command line options. Each represents a distinct config file from which Zig draws runtime behaviour where settings are resolved in a find-first search-order { local, global, global-app, system }.--local
→ work-tree settings (DEFAULT forzig config
)The work-tree is found by walking up the filesystem tree and checking if
.zig
directory exists. Search beings with shell current working directory. If none is found then shell current working directory is used. If a file is found instead of a directory, it is completely ignored. example config file pathnames:/User/mike/project/hello_world/.zig/config
--global
→ home settingsSettings are stored in locations private to a single user account. These locations are based on platform convention for "dot files" in home directories. For platforms where dot files are not applicable then this convention vanishes, and
--global-app
takes its place. examples config file pathnames:/users/mike/.zigconfig
linux/Users/mike/.zigconfig
macOSnote: for platforms where dot files are not applicable then
--global
is replaced with--global-app
semantics--global-app
command-line option vanishes--global-app
→ home app area settingsIf a user wants to keep settings adjacent to other things like zig-cache. example config file pathnames:
/users/mike/.local/share/zig/config
→ linux/Users/mike/Library/Application Support/Zig/config
→ macOS--system
→ zig install settingsZig knows how to determine its install location. From install location a settings location is derived. examples config file pathnames:
/etc/zig/config
→ core bundling with an OS/usr/local/etc/zig/config
→ add to an OS/Applications/Zig.app/Contents/Zig/etc/config
→ macOSThe text was updated successfully, but these errors were encountered: