starship: Allow Elixir module to use `elixir --short-version` because `elixir --version` is very slow
Feature Request
Is your feature request related to a problem? Please describe.
Requesting the Elixir version can take upwards of 700ms, because elxiir --version starts the entire VM. This can cause the prompt to frequently timeout or seem very slow.
Describe the solution you’d like
Since Elixir v 1.13.0 there is a --short-version switch. This doesn’t start the VM and returns results in less than 10ms, but it can only show the full version of Elixir and not OTP. It would be nice if there was a way to make use of this.
The most complex but exhaustive option would be:
if format configuration does NOT contain "$otp_version"
and the elixir value from the mix.exs file (e.g. elixir: "~>1.13") and that version 1.13 or greater
then use the `--short-version` command
Alternatively simply providing a configuration switch that uses elxiir --short-version, but that would have to come with caveats that it will fail on versions older than 1.13 and will not provide the OTP version.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 18 (1 by maintainers)
My custom script just in case someone find it useful:
It uses
--short-versionand if that’s not working then it will use--version. It may be slower for old versions, so I guess use it if most of your projects are running 1.13+also pasted the custom elixir config to get elixir and otp version from asdf
Nice find!
This looks like you are relying on the path containing the otp version using
type elixir. It looks like this install script installs both Erlang and Elixir, which means it can put both versions in the path.I think most tools like
apt,pacman,brew, etc and version managers ikeasdf,mise, etc all expect Erlang as a separately installed package. So the path alone doesn’t really have any information about the OTP version or potentially even the version of Elixir. Before the addition of--short-versionthe only reliable way to get the version was to runelixir -vwhich starts the whole VM just to print the version string.@kris524 It looks like @DonizeteVida is still working on this.