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

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

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog/etc-dub-settings-json.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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.
10 changes: 9 additions & 1 deletion source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,15 @@ class Dub {
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)
Expand Down