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

Respect REBAR_GLOBAL_CONFIG_DIR on global_config/0 #2667

Closed
wants to merge 1 commit into from

Conversation

elbrujohalcon
Copy link

If I'm on a folder without a rebar.config file and I run the following command…

$ REBAR_GLOBAL_CONFIG_DIR=/my/path DIAGNOSTIC=1 rebar3 help

…I would like rebar3 to pick up the plugins I have configured in /my/path/rebar.config and not the ones in ~/.config/rebar3/rebar.config.

If I'm on a folder without a `rebar.config` file and I run the following command…

```bash
$ REBAR_GLOBAL_CONFIG_DIR=/my/path DIAGNOSTIC=1 rebar3 help
```

…I would like `rebar3` to pick up the plugins I have configured in `/my/path/rebar.config` and not the ones in `~/.config/rebar3/rebar.config`.
Copy link
Collaborator

@ferd ferd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I'm not sure. This is the call for the default value. The actual config dir to use is requiring the State variable:

rebar3/src/rebar_dir.erl

Lines 136 to 159 in d4f52f4

%% @doc returns the directory where the global configuration files for rebar3
%% may be stored.
-spec global_config_dir(rebar_state:t()) -> file:filename_all().
global_config_dir(State) ->
filename:join([rebar_config_dir(State), ".config", "rebar3"]).
rebar_config_dir(State) ->
case os:getenv("REBAR_GLOBAL_CONFIG_DIR") of
false ->
rebar_state:get(State, global_rebar_dir, home_dir());
ConfDir ->
ConfDir
end.
%% @doc returns the path of the global rebar.config file
-spec global_config(rebar_state:t()) -> file:filename_all().
global_config(State) ->
filename:join(global_config_dir(State), "rebar.config").
%% @doc returns the default path of the global rebar.config file
-spec global_config() -> file:filename_all().
global_config() ->
Home = home_dir(),
filename:join([Home, ".config", "rebar3", "rebar.config"]).

My guess is that the function is correct, but it's not the one you actually want to call.

So I assume there's a bug in

GlobalConfigFile = rebar_dir:global_config(),
GlobalConfig = rebar_state:new(rebar_config:consult_file(GlobalConfigFile)),
where the wrong version of the function is being called?

@elbrujohalcon
Copy link
Author

Maybe?
I checked the code and found only one call to the /1 version of the function and a bunch of calls to /0… 🤷🏻

ferd added a commit to ferd/rebar3 that referenced this pull request Feb 16, 2022
@ferd
Copy link
Collaborator

ferd commented Feb 16, 2022

Superceded by #2683

@elbrujohalcon elbrujohalcon deleted the patch-1 branch March 1, 2022 10:27
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.

2 participants