-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Add support for new rebar3 output dir option #10018
Add support for new rebar3 output dir option #10018
Conversation
lib/mix/lib/mix/rebar.ex
Outdated
@doc """ | ||
Returns the version of the available `rebar` command if any | ||
""" | ||
@rebar_vsn_regex ~r/^## Rebar3 (?<vsn>[\w\.\d]+)$/m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefix isn't always ##
. That is only for the ones that are installed with rebar3 local install
.
The escript will have %%
. And I just realized only the non-escript has a space there. escript is %%Rebar3 <vsn>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The escript is %% Rebar3 version
; the actual escript generator thing inserts the space itself:
→ head -n2 rebar3
#!/usr/bin/env escript
%% Rebar3 3.14.0-rc1
Otherwise it is true that it sometimes is ## and sometimes is %%. Also if you use asdf, the shim spacing is different:
$ cat `which rebar3`
#!/usr/bin/env bash
# asdf-plugin: rebar 3.13.2
exec /usr/local/opt/asdf/bin/asdf exec "rebar3" "$@"
Also the thing to worry about is the semver-like pre-release flags:
%% Rebar3 3.14.0-rc1
So if you want to be sure, the regex likely looks like ^(##|%%).*[Rr]ebar3? (?<vsn>[\w\d.-]+)$
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ferd Does the asdf shim have one or octothorps? Not sure if you typed that out or if it was copy/paste.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the asdf plugin should affect this though. Doesn't mix always use it's own copy of rebar and not the system one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry for the noise. I now see there's an option to use rebar from an env var. In that case could it make sense to always require new rebar when running the "local" one, but just call --version
on the global one? How slow is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked with someone using asdf, mix should not end up referring to a shim, just escript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still worried about the implications of this version check. It means folks can be using the same Rebar version but installed in different ways and they won't get the same behaviour. :/ Whatever check we do it is impossible to guarantee it will work on all the different ways rebar can be installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct. But all of that is done as a nicety so mix doesn't have to call and cache the result of rebar3 version
which successfully prints the full version since before the first alpha release, and which would be the true safest approach.
end | ||
|
||
defp rebar_compile_cmd_for(vsn, rebar_path, build_path, lib_path) do | ||
case Version.compare("3.12.2", vsn) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.13.2 is the first one to support to be version annotated; 3.13.1 the first one to support the -o option. The moment you got an annotation you got something newer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wondered if doing the Version comparison was overkill... sounds like it. Should probably still parse the Version to make sure it wasn't junk but that should happen in rebar_vsn/1
. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to do a comparison, you just have to check if it is exists.
So, I booted up a VM with windows 10 and I could not replicate the problem I'm seeing in CI in that, I used a similar path with escapes and so forth and was able to That said, I could not run the tests myself as I could not get elixir to compile per a unicode properties compilation error. I can't paste the error, but I took a screen shot. However, I don't think the compilation error I got is relevant at all, but can share here if desired. My thought at the moment is that this problem is limited to the CI environment for windows or possibly the test setup itself (i.e., it may be the file isn't actually there). |
Hi @starbelly, a quick heads up: we talked about this in the Build and Packaging WG and we agreed to go down the environment variable route. So first we will add the environment variable support to Rebar 3.14 and then pass it here in Mix. Regarding the Windows problem, we had the same issue on another test in the past, and we just stopped running that particular test on Windows. Windows is a bit tricky when it comes to removing files: I believe it takes a while for Windows to notice the file is no longer being used, which leads to races. |
May as well add the env variable to mix now. Sooner it is in the better for users. |
Right, so I'm synced up... Are we wanting to add said env var check in this PR? |
We will set the variable from Mix but rebar3 needs to be patched to read from it. |
@josevalim right, but it doesn't need to be patched before mix starts setting the environment variable. |
As long as we agree on the name. :) |
80f7531
to
d39a3d6
Compare
rebar3 as of 3.13.2 now supports a --output directory option which allows mix going forward to use said option and put build artifacts in _build which should result and less rebuilding of artifacts and/or better caching of artifacts. Details here: erlang/rebar3#2237 In order to make use of said feature we must put a variable in the system's environment that shall hold the desired output path. rebar3 will recognize said environment variable going forward starting at version 3.14 (yet to be released). - Updated Mix.Tasks.Deps.Compile to put REBAR_BARE_COMPILER_OUTPUT_DIR in system env with the dependency path as the value for use by rebar3.
d39a3d6
to
ddc3e3f
Compare
@josevalim @tsloughter @ferd The PR has been updated to just putting the env var in place. Updated description of issue and commit message. |
@@ -189,7 +189,10 @@ defmodule Mix.Tasks.Deps.Compile do | |||
lib_path = Path.join(config[:env_path], "lib/*/ebin") | |||
|
|||
env = [{"REBAR_CONFIG", config_path}, {"TERM", "dumb"}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing it with System.put_env
, you can define the environemnt variable here. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣 Got it!
💚 💙 💜 💛 ❤️ |
This option will be enabled on Elixir v1.12 instead. This reverts commit fc9f769.
rebar3 as of 3.13.2 now supports a --output directory option which allows mix going forward to use said option and put build artifacts in _build which should result and less rebuilding of artifacts and/or better caching of artifacts. Details here: erlang/rebar3#2237
In order to make use of said feature we must put a variable in the system's environment that shall hold the desired output path. rebar3 will recognize said environment variable going forward starting at version 3.14 (yet to be released).