hendriknielaender/zvm

windows support [tracking issue]

Closed this issue ยท 17 comments

Great project, I've forked the repo and I'll try to add windows support

I briefly took a look at the current implementation and to be honest, it's a bit weird.

Currently, symbolic links are used, and getenv is used to obtain home. These are mainly due to these two problems. On Windows, symbolic links require administrator rights or SeCreateSymbolicLinkPrivilege right.

For env, we can use std.process.getEnvVarOwned, that is cross platform

This means that simply using symbolic links is not user-friendly. Can we copy the file directly?

And I checked other zig version managers, and the results donโ€™t look ideal.
And most of them lack Windows support. Indeed, the Windows API is very strange, and Zigโ€™s support for Windows is not very good.

Hi @jinzhongjia,

Cool that you like the project! I'm thrilled to hear that you are working on adding Windows support. Contributions are greatly appreciated.

Regarding the use of symbolic links, I agree that the current implementation poses challenges, especially on Windows where symbolic links require special permissions. Given zig's limited support for symlinks on Windows, my first suggestion is to consider using some native C libraries until Zig's api got better. This approach worked well for us with the extraction (libarchive) function in versions 0.1 and 0.2 of zvm.
#24

Feel free to reach out if you need any assistance or have more ideas to discuss. I'm happy to help!

Native c library? Aha
Is there any C library that supports creating symbolic links without permissions?

No, not for symlinks ๐Ÿ˜… I meant more the general approach. I think your idea of copy/creating the file instead should work, something like this:

const symlink = try std.fs.path.join(allocator, &[_][]const u8{ dir, "master" });
defer allocator.free(symlink);
if (builtin.os.tag == .windows) {
  var file = try std.fs.createFileAbsolute(symlink, .{});
  defer file.close();
  try file.writer().writeAll(url.version);
}

I get it

image
Now, I have made it compile under windows and output help. I still need to do some additional tests.

Currently I'm stuck on decompressing the zip. I don't understand why zig's zip function is designed so strangely.

It requires me to specify a decompress_size, strange behavior

Ok I found some related examples and I will try it
ziglang/zig#19729
ziglang/zig#17408

image
There is currently no problem running the program, but the following paths need to be adjusted

In addition, I wonder if we can expose the various functions of the whole to the outside world as modules?
This will make it easier for others to integrate

In addition, I wonder if we can expose the various functions of the whole to the outside world as modules? This will make it easier for others to integrate

Could you please provide more specific details on what you mean by "exposing the various functions of the whole to the outside world as modules"? To ensure we address this properly, it would be helpful if you could open an issue with the detailed requirements and use cases.

To put it simply, it just exposes the package to the outside world to facilitate third-party calls.