{"action":"created","issue":{"url":"https://api.github.com/repos/dlang/dmd/issues/7915","repository_url":"https://api.github.com/repos/dlang/dmd","labels_url":"https://api.github.com/repos/dlang/dmd/issues/7915/labels{/name}","comments_url":"https://api.github.com/repos/dlang/dmd/issues/7915/comments","events_url":"https://api.github.com/repos/dlang/dmd/issues/7915/events","html_url":"https://github.com/dlang/dmd/pull/7915","id":298168436,"number":7915,"title":"Improve the lookup sequence for finding the config file","user":{"login":"wilzbach","id":4370550,"avatar_url":"https://avatars3.githubusercontent.com/u/4370550?v=4","gravatar_id":"","url":"https://api.github.com/users/wilzbach","html_url":"https://github.com/wilzbach","followers_url":"https://api.github.com/users/wilzbach/followers","following_url":"https://api.github.com/users/wilzbach/following{/other_user}","gists_url":"https://api.github.com/users/wilzbach/gists{/gist_id}","starred_url":"https://api.github.com/users/wilzbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilzbach/subscriptions","organizations_url":"https://api.github.com/users/wilzbach/orgs","repos_url":"https://api.github.com/users/wilzbach/repos","events_url":"https://api.github.com/users/wilzbach/events{/privacy}","received_events_url":"https://api.github.com/users/wilzbach/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-19T05:54:32Z","updated_at":"2018-02-19T05:54:32Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/dlang/dmd/pulls/7915","html_url":"https://github.com/dlang/dmd/pull/7915","diff_url":"https://github.com/dlang/dmd/pull/7915.diff","patch_url":"https://github.com/dlang/dmd/pull/7915.patch"},"body":"In short, it's very problematic that `~/dmd.conf` has a higher precedence than the config next to the dmd binary.\nThis easily leads to unexpected behavior.\nI think @MartinNowak has a very good explanation at https://github.com/dlang/dmd/pull/4256#issuecomment-88316771:\n\n---\n> tl;dr, please reconsider changing the conf order or splitting the conf file\n\n> That dmd.conf is driving me crazy.\n\n> I need a dmd.conf in my dmd repo, so that I can use dmd-master. It wouldn't work without a config and putting `dmd.conf` anywhere but near dmd itself overrides my system dmd.conf.\n> That setup worked nicely for me although some of you guys seem to have a dmd.conf in your home dir (why?).\n\n> Now that we require a host D compiler to build dmd it no longer works, because the dmd.conf for my dmd-master overrides the system wide dmd.conf of my host dmd.\n> Why would my system dmd need a different configuration just because **I** am in a different folder?\n> It doesn't, it still uses the same phobos (the system wide) and still requires the same linker switches.\n\n> Setting HOST_DC is a workaround but is impractical, because it requires an awkward `env HOST_DC='dmd -conf=/etc/dmd.conf' make -f posix.mak` to work.\n> Requiring `dmd -conf=/etc/dmd.conf` in order to not pickup some random conf file is crazy. It's not portable either, because the config is somewhere else on each platform.\n\n> We learned the same from dlang.org https://github.com/D-Programming-Language/dlang.org/pull/758#issuecomment-74294012, adding the `-conf=` switch didn't solve the actual problem and created new ones.\n\n> It might seem intuitive, that a local configuration should override a global one, but it's a false friend here, because the configuration should be local from the perspective of the compiler, not from the perspective of the user.\n\n> In fact the config is so tied to the compiler that we could almost compile it **into** the compiler (like gcc does with it's spec). At best it's something package maintainers need to touch to accomodate platform differences, but it's not a user configuration file. \n\n> If people use it to configure DFLAGS and such project dependent stuff, then we need to split the configuration file, into one part that tells the compiler where to find druntime/phobos and how to link, and one part that can be used for per-project configuration of compiler arguments and env variables.\n> IMO the latter is better kept in makefiles/dub.json though.\n\n> ### conclusion\n\n> The lookup order for the config file should be changed to the following.\n> - next to dmd binary (highest precedence so that I can have multiple installations)\n> - per-user conf folder (HOME) (to override the system-wide config)\n> - system-wide conf folder (to allow package installations .deb/.rpm)\n\n> The current situation is unmaintainable.\n---\n\nLDC's search oder\n-----------------\n\nFWIW I think [LDC's search order](https://wiki.dlang.org/Using_LDC) is nice and we should learn from them:\n\n- current working directory\n- next to binary\n- ~/.ldc\n- user home directory (Windows-only)\n- in an etc directory next to the directory where the binary resides\n- install-prefix (Windows-only)\n- install-prefix/etc\n- install-prefix/etc/ldc\n- /etc\n- /etc/ldc\n\nOther path DMD should look at:\n- [Issue 4586 - DMD should look for dmd.conf in /usr/local/etc](https://issues.dlang.org/show_bug.cgi?id=4586)\n- [Issue 5445 - DMD does not look for \".dmd.conf\" in HOME dir](https://issues.dlang.org/show_bug.cgi?id=5445)\n\nResulting issues I found on a quick scan:\n- [Issue 18145 - Phobos makefile incorrectly sets --dip1000 for DMD when BUILD=debug](https://issues.dlang.org/show_bug.cgi?id=18145)\n- [Issue 17880 - Build of dlang.org affected by presence of ~/dmd.conf](https://issues.dlang.org/show_bug.cgi?id=17880)\n\n\nAs you can see the current status quo is a mess. I'm more than happy to fix the two open issues in this PR too. Here's the order I suggest\n\n- current working directory\n- exe directory (windows)\n- directory of argv0\n- ~/.dmd.conf\n- ~/dmd.conf (legacy :/)\n- user home directory (Windows-only)\n- install-prefix/etc/dmd.conf\n- SYSCONFDIR=/etc (non-windows)"},"comment":{"url":"https://api.github.com/repos/dlang/dmd/issues/comments/366595279","html_url":"https://github.com/dlang/dmd/pull/7915#issuecomment-366595279","issue_url":"https://api.github.com/repos/dlang/dmd/issues/7915","id":366595279,"user":{"login":"dlang-bot","id":15698993,"avatar_url":"https://avatars3.githubusercontent.com/u/15698993?v=4","gravatar_id":"","url":"https://api.github.com/users/dlang-bot","html_url":"https://github.com/dlang-bot","followers_url":"https://api.github.com/users/dlang-bot/followers","following_url":"https://api.github.com/users/dlang-bot/following{/other_user}","gists_url":"https://api.github.com/users/dlang-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang-bot/subscriptions","organizations_url":"https://api.github.com/users/dlang-bot/orgs","repos_url":"https://api.github.com/users/dlang-bot/repos","events_url":"https://api.github.com/users/dlang-bot/events{/privacy}","received_events_url":"https://api.github.com/users/dlang-bot/received_events","type":"User","site_admin":false},"created_at":"2018-02-19T05:54:32Z","updated_at":"2018-02-19T05:54:32Z","author_association":"CONTRIBUTOR","body":"Thanks for your pull request, @wilzbach!\n\n### Bugzilla references\n\nYour PR doesn't reference any Bugzilla issue.\n\nIf your PR contains non-trivial changes, please [reference a Bugzilla issue](https://github.com/dlang-bots/dlang-bot#automated-references) or create a [manual changelog](https://github.com/dlang/dmd/blob/master/changelog).\n"}}
{"actor":{"display_login":"dlang-bot"}}