-
Notifications
You must be signed in to change notification settings - Fork 517
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
Properly use XDG specs #2592
Open
hauleth
wants to merge
1
commit into
erlang:main
Choose a base branch
from
hauleth:fix/properly-use-xdg-paths
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Properly use XDG specs #2592
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,16 +133,22 @@ home_dir() -> | |
{ok, [[Home]]} = init:get_argument(home), | ||
Home. | ||
|
||
basedir(Type) -> | ||
filename:basedir(Type, "rebar3", #{os => linux}). | ||
|
||
%% @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"]). | ||
case rebar_config_dir(State) of | ||
undefined -> basedir(user_config); | ||
Path -> filename:join([Path, ".config", "rebar3"]) | ||
end. | ||
|
||
rebar_config_dir(State) -> | ||
case os:getenv("REBAR_GLOBAL_CONFIG_DIR") of | ||
false -> | ||
rebar_state:get(State, global_rebar_dir, home_dir()); | ||
rebar_state:get(State, global_rebar_dir, undefined); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this now |
||
ConfDir -> | ||
ConfDir | ||
end. | ||
|
@@ -155,14 +161,12 @@ global_config(State) -> | |
%% @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"]). | ||
filename:join([basedir(user_config), "rebar.config"]). | ||
|
||
%% @doc returns the location for the global cache directory | ||
-spec global_cache_dir(rebar_dict()) -> file:filename_all(). | ||
global_cache_dir(Opts) -> | ||
Home = home_dir(), | ||
rebar_opts:get(Opts, global_rebar_dir, filename:join([Home, ".cache", "rebar3"])). | ||
rebar_opts:get(Opts, global_rebar_dir, basedir(user_cache)). | ||
|
||
%% @doc appends the cache directory to the path passed to this function. | ||
-spec local_cache_dir(file:filename_all()) -> file:filename_all(). | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Oh, hm, if we are going to do this we probably shouldn't hardcode
linux
. It may change where stuff goes in windows and osx but probably better to be right than continue being wrong? But not sure...@ferd 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.
Replace my "may" with "will". https://erlang.org/doc/man/filename.html#basedir-3
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 on macOS and I prefer my development tooling to use XDG rather than macOS practices ;)
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.
This may unfortunately blow out things in the global rebar.config file and existing hex auth and be considered backwards incompatible in very surprising ways.
If we're to support the new stuff, it should ideally come with supporting both at once with a warning or information message asking the user to move content, which they may hate if they have to use various rebar3 versions for various OTP support (or when building with mix, which bundles older ones).
Forcing the linux path likely keeps things compatible with the current mechanism on all operating systems though, since it's what we forced everywhere (would have to double check windows)
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.
Yea. I suppose we can wait for rebar4.
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 in what way it can blow things? It would only change behaviour if user have set
XDG_CONFIG_HOME
.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.
Using it with the linux path everywhere should remain the same although there's a check needed for windows because I don't know if they're fully equivalent. Following the basedir fully would break stuff.
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 what check for windows are you referring to?
I think this PR is good to merge except for a question I have on line 151.
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 think we're fine if we keep forcing the linux format. I just double-checked, the thing that worried me is that there could be a conversion issue between what was considered the home_dir() in windows as of today vs. how the Linux path would translate.
I did a check on my old win10 machine and it seems to be identical and good to go.