asdf-elixir
asdf-elixir copied to clipboard
Add auto install of hex and rebar including path of the freshly installed elixir
The problem was that the newly installed elixir wasn't in the path. This is because reshim happens after installation of elixir. There is no default post-install which could take place after the reshim.
I tested this on a fresh install and it worked.
@dobs would you be so kind to confirm if this fix is proper and working in your environment? Sorry for the trouble :)
@tverlaan can you rebase on master so the Travis build runs correctly now?
Perfect! It fails. I was actually expecting this since the erlang that's part of the default Xenial doesn't seem to want to run elixir (and OSX doesn't have erl at all).
Thanks for iterating on this @tverlaan.
Unfortunately there still appear to be some quirks, at least when testing locally:
$ asdf plugin-add elixir ../asdf-elixir
Cloning into '/Users/dobs/.asdf/plugins/elixir'...
done.
$ asdf install
erlang 22.1 is already installed
==> Checking whether specified Elixir release exists...
==> Downloading 1.9.4-otp-22 to /var/folders/8t/bcy9yfg90c56_4m_36wmtyrm0000gp/T//elixir-precompiled-1.9.4-otp-22.zip
** Resuming transfer from byte position 5274462
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
==> Copying release into place
** (CompileError) config/config.exs:10: module Config is not loaded and could not be found
(elixir) lib/code.ex:232: Code.eval_string/3
(mix) lib/mix/config.ex:220: Mix.Config.eval!/2
** (CompileError) config/config.exs:10: module Config is not loaded and could not be found
(elixir) lib/code.ex:232: Code.eval_string/3
(mix) lib/mix/config.ex:220: Mix.Config.eval!/2
I can whip up and share a quick bootstrap project and some commands to reproduce if necessary. I'm guessing this is another path issue?
It does make me somewhat cautious of this change more broadly -- ~~it assumes you're already inside of a valid Elixir project in order to install Elixir. It would also cause issues for anyone working on poncho-style projects.~~ EDIT: I'm wrong about installing outside of an existing project -- that appears to work. But project specifics look like they can trip this up.
Thanks a lot @dobs for helping me test! I'm afraid you're right. I'll try to reproduce and fix it, if you can provide something that would speed me up.
On the first iteration I was considering making it configurable with an env var. Another option would be an additional file in ~/ similar to asdf-nodejs. I also found an option to do it with ~/.asdfrc, however that requires a bit more fiddling.
@dobs & @Stratus3D , I found some time to work on this again. I took a different approach which is 1, a bit more flexible and 2, not changing the default behavior. In the end it's similar to the approach as in asdf-nodejs.
I tested it in existing projects & outside of any projects. ~~However if a project contains a bug in the mix.exs file or in the project config it will break. This is because mix always evaluates the project file and configuration in order to load any aliases (and probably other things). I'm not sure if I should cater for this as you can always remove the .default-mix-commands file or fix the bug in your project.~~
Thanks @tverlaan ! I like this approach. Do any of the other Elixir version managers follow this pattern?
@danhper what do you think of this?
This feature is not supported by any of the other version managers afaict.
Hi! I just stumbled on this PR while looking to see if this feature existed. I was wondering if someone found a showstopper since the last post or whether everyone just got busy. If it's the latter and it's basically read to go, perhaps I can help test so that it could be merged?
I've been running my version ever since and it works like a charm every single time. I even forget about it until I install a newer version of elixir.
❯ cat .default-mix-commands
local.rebar
local.hex
archive.install hex phx_new
I'm working to get this merged this week. But first I need to finish getting this project setup on Github actions which will include adding some code quality checks. I want to make sure these changes pass the new checks before I merge.
@Stratus3D Thank you! It's hard to convey how much time that asdf and this plugin have saved me. I really appreciate all of the work that you've put into this. Also, thanks @tverlaan for implementing this feature! I was on the verge of implementing it and super glad that I saw your PR.
Thanks @fhunleth , glad it's been helpful!
@tverlaan I just merged the updated Github workflow. Can you rebase onto latest master and fix any linter warnings? Checks should run for every PR update now.
Thanks for the PR @tverlaan ! And thanks for updating it to pass with the new CI process. Sorry for taking over 2 years to get this merged 😬
Better late than never 😁 . Thanks!!