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

Allow to specify version from command line or via environment variables #21

Open
voxik opened this issue Sep 8, 2022 · 5 comments
Open

Comments

@voxik
Copy link

voxik commented Sep 8, 2022

RubyGems has stubs doing something similar to alts and they supports to execute the alternative version from command line, e.g. given there is rdoc command, you can run rdoc _4.6.0_ which executes the 4.6.0 version.

Similarly, there is used rubypick on Fedora to execute Ruby, where there are also supported environment variables to influence the version executed.

@voxik
Copy link
Author

voxik commented Sep 8, 2022

Apart from this, for development purposes, I have always dreamed, if I can put into my project some dot file, which would help to override the system defaults for specific project (BTW this is something similar to what Windows does with manifest files).

@voxik
Copy link
Author

voxik commented Sep 8, 2022

for development purposes

Or maybe even for runtime? E.g. if shebang specified /urs/bin/ruby and it would be atls link, this would allow to choose runtime version of Ruby without changing the shebang ....

@AdamMajer
Copy link
Member

for development purposes

Or maybe even for runtime? E.g. if shebang specified /urs/bin/ruby and it would be atls link, this would allow to choose runtime version of Ruby without changing the shebang ....

Yes, this is what it does already. It does runtime re-exec of some name, like /usr/bin/node, to a specific versioned one, like /usr/bin/node18. The path is not even taken into account, so you could do this like /home/user/bin/ruby -> /usr/bin/alts and have it redirect based on some priority setting.

Currently, the overrides happen on system or user level. So for users, at present it will look in your XDG_CONFIG_HOME/libalternatives.conf, or if not available, then under HOME/.config/libalternatives.conf for the user settings. This means one override per user.

What could be done is something like LIBALTERNATIVES_CONFIG_FILE env variable that could be used to override the user config location. This could then have override version specific to your execution environment. This could be per project or even more granular.

What do you think?

@voxik
Copy link
Author

voxik commented Apr 7, 2023

I think that first something like libalternatives.conf could be looked up the directory structure.

@AdamMajer
Copy link
Member

This would change behaviour quite a bit from current and also it would be less efficient. It would mean reading directory of every parent until there is something found (like nodejs, for example).

But if we went with it, it would need another env variable for this alternative behaviour. so something like, LIBALTERNATIVES_CONFIG_RESOLUTION_MODE=1 could be an option.

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

No branches or pull requests

2 participants