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

Make zigup configurable through an enviroment #154

Closed
wants to merge 19 commits into from

Conversation

Mulling
Copy link

@Mulling Mulling commented Nov 24, 2024

This PR adds a few things and ideas:

Overall, this makes zigup work when installed globally (from a package manager); and allows persistent configuration. For now, only tested on Linux.

* First step into making this actually useful without a lot of prior
setup. Try to copy what rustup does.
* This make so that it's possible to configure zigup through an .env file
which just sets `$ZIGUP_DIR` and `$ZIGUP_INSTALL_DIR`. The current
active compiler then is just `$ZIGUP_DIR/current`, which is in the `$PATH`.
* Test if the current terminal is a tty so we can ask the user things.
* `undefine` will undefine the current default compiler, this is useful
  for using a system-wide installation of zig.
* Since now we allow for arbitrary paths to be set as the default
  compiler, we can't use the path to determine the version. Instead, use
  `zig version` to do so.
@Mulling Mulling marked this pull request as draft November 24, 2024 18:06
@Mulling Mulling changed the title Make zigup configurable through an enviroment. Make zigup configurable through an enviroment Nov 24, 2024
@marler8997
Copy link
Owner

See my comments on other issues/PRs for my thoughts on adding support for environment variable configuration.

@Mulling
Copy link
Author

Mulling commented Nov 25, 2024

Care to explain? You could do away with the environment variables, that's not a problem, it'd still need an environment (like cargo and others). + it would allow for zigup to be packaged, without the problems from it being in the global path that happen now. This also avoids having the user pass --install-dir all the time or creating aliases.

@marler8997
Copy link
Owner

Previous comment/thoughts here: #91 (comment) (see the linked comment in that comment)

I'm not aware of any problems with packaging zigup at the moment.

@Mulling
Copy link
Author

Mulling commented Nov 25, 2024

I'm not aware of any problems with packaging zigup at the moment.

Using the AUR package as an example: zigup gets installed under /usr/bin/ and attempts to symlink the downloaded version to /usr/bin/zig. This not only breaks a multi-user system, but also does not allow the user to have zig installed through the package manager. Solution is to use --path-link, which comes back to the problem at hand.

If contributions are welcomed I'm happy to make changes, like removing the environment variables (still need an environment to configure the PATH).

@marler8997
Copy link
Owner

Ah i see yes that is a problem. I'm thinking the solution here might be to add a build-option so that distribution maintainers can specify the default path-link at build time for their distribution. What do you think? Does arch have a standard directory for the user to place binaries (or in this case a symlink to a binary) meant to be accessible via PATH ?

@Mulling
Copy link
Author

Mulling commented Nov 25, 2024

Most distros will have ~/.local/bin in the PATH, you could use that. I still think an env file that just adds a path in the zigup install dir to the PATH is a better option (rustup/cargo, ghcup, etc... all use this approach).

@marler8997
Copy link
Owner

Well I have no problem with adding a build option to change the default path link, something like zig build -Dpath-link=~/.local/bin sounds fine to me. Adding support for environment variables and environment files would be adding complexity that I think would need justification. That's the type of complexity that makes triaging issues a pain as you now need to know alot more about the user's environment to understand whats going on.

@Mulling
Copy link
Author

Mulling commented Nov 25, 2024

Understandable, I will maintain a fork here: https://github.com/mulling/zup with the changes above and more, if anyone is interested.

@Mulling Mulling closed this Nov 25, 2024
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.

Add a symbolic link to the files of the default compiler
2 participants