-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
use an additional, project-local copy of dependency trees #14283
Comments
Is it correct that the idea is:
|
this approach for local dependencies is problematic, particularly on windows and is very noticeable in the node ecosystem when using the default a flat |
Yep, i agree on that. A flat namespace will support deduplication and make it more clear which packages are actual dependencies, also keeps you aware of how many deps you actually have. Duplicate names can be resolved by appending the hash, even if this would make it a bit weird for the user to debug. Another option would be to make transitive duplicates named |
Why not store the deps in the local zig cache? It is ephemeral anyway, and can be viewed as a cache (because they can be recomputed/re-downloaded).
This is not a problem on some modern filesystems (definitely on btrfs and xfs, there may be more) due to copy-on-write. As of some recent coreutils even Reflinking is not the default mode in zig (I have that in my backlog), but will become at some point. |
because of this:
|
One option to reduce disk space without symlinking (which causes all sorts of other issues and largely removes the benefit of this proposal) is to use hard links. This is only possible on some operating systems, and only if the project and global cache are on the same drive, but it would solve the disk space problem with basically no added complexity. |
Npm with flat "tree" has a problem with importing transitive dependencies: I have a question what is my workflow will be if I need to patch one of transitive dependency? If local tree is created during |
On idea could be that zig stores the compressed archives in the global cache, and only extracts them when installing to a local project. This would minimize disk space usage and helps ensure the original contents of the dependency remain intact (developer doesn't accidentally modify the contents of the files in the global cache). Also means there's no temptation or path to using "symlinks" to the global cache files. |
On IRC I asked whether we should store decompressed archives in the global cache, so we can use more efficient means to decompress the file (I mentioned Turns out more efficient ways to decompress the file are not that more efficient. GNU tar wins (unsurprisingly, it is well optimized), followed by Andrew's stdlib implementation which uses pread/pwrite. sendfile and copy_file_range are a bit slower, definitely not worth the added complexity.
Files: Built with:
|
The zig-cache directory is intended to be excluded from source control. |
I've created a PR for this #20150. Although that the moment the package hash is currently just stored "as-is" in
Potentially using a lock file or some-such to keep track of things and having the ability to force hashes to be re-checked based on the folder contents of the packages. I'm sure there's a fair few things I have failed to consider... but hopefully by addressing feedback on this I can hopefully construct a mergeable PR that solves all the problems that need to be solved. I don't know if this is overcomplicating things relative to:
But I do think the concern of how deep those paths could get on Windows to be legitimate. And it would be nice to avoid copying packages locally within a repository at a minimum. (although my stealth hot-take is that transitive dependencies are way more hassle then they are worth, and libraries should be really, really judicial about using them at all in the first place). |
Hi, I'm here with real-word use-case scenario. Recently attempted to package zls for sisyphus. The thing is that sisyphus requires so that source tarball/git repo builds without internet connection. It would be nice to have something like |
edit: the issue was also that they were doing a http request in their configure phase |
zig fetch (or zig build --fetch) uses zig-cache directory. As Andrew said it is not intended to be commited to the source tree. zig-deps folder with all dependencies names would be nice to have. Though I admit it seems it is possible to build zig project in offline with |
After tinkering for a while found out that there is a flag |
Closing in favor of #20180. I think this use case is solved with a combination of that, plus some follow-up tooling, plus the |
Extracted from #14265.
Terminology clarification:
@import
.Currently, zig puts all fetched dependencies in the global zig cache, like this:
Then, dependencies are used directly from this directory, and shared among all projects.
This proposal is for
zig build
to additionally copy each dependency from the global cache into a project-local directory, like this:A transitive dependency would look like this:
This would be similar to the node_modules directory from npm.
Motivations:
Downsides:
zig-deps
.Open question: where to store the hash? It's nice to use the dependency name instead of the hash for the directory name, but it does leave the problem of how
zig build
should detect whether a dependency needs to be updated or not. It can always recompute hashes, but it should not be recomputing hashes on everyzig build
. Ideally, it would be only one open() call to open the directory of a dependency and find out whether the desired hash is present or not.The text was updated successfully, but these errors were encountered: