Posix: use /etc/dub/settings.json if in /usr
Fix #1472

/etc/dub/settings.json overrides /usr/etc/dub/settings.json (as
suggested by the `man hier` manpage)
1 parent 43b7992 commit 059f7a2a16cf7a50a5c68dc295c796482116ff87
@WebFreak001 WebFreak001 authored on 17 Feb 2022
The Dlang Bot committed on 31 Mar 2022
Showing 2 changed files
View
10
changelog/etc-dub-settings-json.dd 0 → 100644
Posix: use /etc/dub/settings.json if DUB is installed in /usr
 
For Linux distributions that put the dub installation in /usr, there is now a
special case that DUB will load from /etc/dub/settings.json (absolute path) if
the installation is inside /usr.
 
Previously settings would have attempted to be loaded from
`/usr/etc/dub/settings.json` if installed in `/usr/bin/dub`. This is still
loaded if it exists, but if not `/etc/dub/settings.json` will be loaded.
View
18
source/dub/dub.d
 
m_dirs.temp = NativePath(tempDir);
 
m_config = new DubConfig(jsonFromFile(m_dirs.systemSettings ~ "settings.json", true), m_config);
m_config = new DubConfig(jsonFromFile(NativePath(thisExePath).parentPath ~ "../etc/dub/settings.json", true), m_config);
 
auto dubFolderPath = NativePath(thisExePath).parentPath;
m_config = new DubConfig(jsonFromFile(dubFolderPath ~ "../etc/dub/settings.json", true), m_config);
version (Posix) {
if (dubFolderPath.absolute && dubFolderPath.startsWith(NativePath("usr"))) {
m_config = new DubConfig(jsonFromFile(NativePath("/etc/dub/settings.json"), true), m_config);
}
}
 
m_config = new DubConfig(jsonFromFile(m_dirs.userSettings ~ "settings.json", true), m_config);
 
if (!root_path.empty)
m_config = new DubConfig(jsonFromFile(root_path ~ "dub.settings.json", true), m_config);