Skip to content
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

windows support [tracking issue] #10

Closed
hendriknielaender opened this issue Sep 26, 2023 · 17 comments
Closed

windows support [tracking issue] #10

hendriknielaender opened this issue Sep 26, 2023 · 17 comments
Labels
enhancement New feature or request

Comments

@hendriknielaender
Copy link
Owner

tbd

@hendriknielaender hendriknielaender added the enhancement New feature or request label Sep 26, 2023
@hendriknielaender hendriknielaender added this to the windows support milestone Sep 26, 2023
@jinzhongjia
Copy link
Contributor

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

@jinzhongjia
Copy link
Contributor

jinzhongjia commented Jun 5, 2024

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?

@jinzhongjia
Copy link
Contributor

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.

@hendriknielaender
Copy link
Owner Author

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!

@jinzhongjia
Copy link
Contributor

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

@hendriknielaender
Copy link
Owner Author

hendriknielaender commented Jun 6, 2024

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);
}

@jinzhongjia
Copy link
Contributor

I get it

@jinzhongjia
Copy link
Contributor

jinzhongjia commented Jun 12, 2024

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

@jinzhongjia
Copy link
Contributor

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

@jinzhongjia
Copy link
Contributor

@jinzhongjia
Copy link
Contributor

It requires me to specify a decompress_size, strange behavior

@jinzhongjia
Copy link
Contributor

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

@jinzhongjia
Copy link
Contributor

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

@jinzhongjia
Copy link
Contributor

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

@hendriknielaender
Copy link
Owner Author

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.

@jinzhongjia
Copy link
Contributor

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

@hendriknielaender
Copy link
Owner Author

#42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants