Re: Expected Config File Locations
On Tue, Aug 30, 2011 at 01:55:48PM +0100, Smylers wrote: Hi. I'm looking for some advice on where I should put the config file for a command I'm distributing on Cpan. Where would you it to be? I'm interested in opinions of Windows, Mac, and Unix users, for both per-user and system-wide config. Some standards already exist that might help your decision. Particularly for user configuration files: The FHS says it should be ~/.bang[/]: http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#REQUIREMENTS4A However, the Freedesktop spec. says ~/.config/bang[/]: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables For system-wide configuration files, I'd want to see anything that isn't part of my distribution in /usr/local, ie. /usr/local/etc/bang[/], but I'd expect it to be put into /etc, just because a lot of software does that. Personally, I prefer ~/.config/bang[/] and /usr/local/etc/bang[/]. This is of course unless the user doesn't specify their own place at some point. But I'd be surprised to find /usr/local/etc/ being used on Linux. On Linux, I already have user-installed packages that use this by default, and a load of things that use ~/.config/. -- .
Re: Expected Config File Locations
David Cantrell writes: > On Tue, Aug 30, 2011 at 01:55:48PM +0100, Smylers wrote: > > > ... advice on where I should put the config file for a command ... > > On Mac and other Unix-a-likes, .${command}rc or .$command for per-user > config, and /etc/$command or /etc/${command}rc for system-wide config. Hi Dave. Thanks for your reply. > On Windows, I presume that it should be in the registry, but Microsoft > may have changed things in the decade since I last had to care. I was thinking the registry would be right for a program that saves its own preferences (probably with a graphical interface for the user to set them), but it doesn't seem appropriate for something users would have to configure manually. > There are plenty of Windows machines that have multiple users, OK. > > * On some Unices such as FreeBSD I've seen /usr/local/etc/ used for > > commands that are installed under /usr/local/. Is that what you'd > > expect? > > I've come to expect it, but I prefer /etc. Fair enough. > > But I'd be surprised to find /usr/local/etc/ being used on Linux. > > I wouldn't. Something that does that on FreeBSD is pretty likely to > also do it on Linux, I would have thought. True. I guess it's more that I have very little software in /usr/local/ on Linux, because most of it comes in packages that install to /usr/. Whereas on FreeBSD, ports install under /usr/local/ and use /usr/local/etc/. Smylers -- Watch fiendish TV quiz 'Only Connect' (some questions by me) Mondays at 20:30 on BBC4, or iPlayer: http://www.bbc.co.uk/onlyconnect
Re: Expected Config File Locations
On Tue, Aug 30, 2011 at 01:55:48PM +0100, Smylers wrote: > Hi. I'm looking for some advice on where I should put the config file > for a command I'm distributing on Cpan. Where would you it to be? I'm > interested in opinions of Windows, Mac, and Unix users, for both > per-user and system-wide config. On Mac and other Unix-a-likes, .${command}rc or .$command for per-user config, and /etc/$command or /etc/${command}rc for system-wide config. On Windows, I presume that it should be in the registry, but Microsoft may have changed things in the decade since I last had to care. > * Most Windows systems seem to be single-user; do I even need both > system-wide and per-user locations on Windows, and if not which one > would you expect to find? Depends on what the program is. There are plenty of Windows machines that have multiple users, even if they can't all be logged in at the same time. > And on Unix: > > * system_cfg_dir always returns /etc/. On some Unices such as FreeBSD > I've seen /usr/local/etc/ used for commands that are installed under > /usr/local/. Is that what you'd expect? I've come to expect it, but I prefer /etc. > File::ConfigDir has local_cfg_dir, which returns /usr/local/etc. So I > could use that if the command has been installed in /usr/local/bin/ > and stick with /etc/ otherwise. > > But I'd be surprised to find /usr/local/etc/ being used on Linux. I wouldn't. Something that does that on FreeBSD is pretty likely to also do it on Linux, I would have thought. -- David Cantrell | Nth greatest programmer in the world I caught myself pulling grey hairs out of my beard. I'm definitely not going grey, but I am going vain.
Re: Expected Config File Locations
On Tue, Aug 30, 2011 at 04:44:10PM +0100, Smylers wrote: > Abigail writes: > > > On Tue, Aug 30, 2011 at 01:55:48PM +0100, Smylers wrote: > > > > > Hi. I'm looking for some advice on where I should > > ... ask users to ... > > > > put the config file for a command I'm distributing on Cpan. Where > > > would you > > ... expect ... > > > > it to be? I'm interested in opinions of Windows, Mac, and Unix > > > users, for both per-user and system-wide config. > > Um, sorry for missing words out of my original question. > > > while directory defaults are found in the current working directory. > > I hadn't considered directory configuration files. Thanks. > > > I can only tell you what I would do. > > Thanks, given that there isn't clearly one right way, opinions are what > I'm seeking. > > > For an application womble, I'd look for $PREFIX/etc/womblerc, and > > /etc/womblerc, loading the first one found. The load $HOME/.womblerc > > (if exists). Finally, look for ./.womblerc, and load that as well (if > > exist). > > OK. By $PREFIX do you mean the parent directory of where the command is > installed -- so /usr/local/bin/womble uses /usr/local/etc/womblerc and > /usr/bin/womble uses /usr/etc/womblerc? > $PREFIX would be whatever prefix is given when configuring the package (for instance, --prefix when running ./configure or Perls ./Configure -Dprefix=) This typically is the parent directory of where the command is installed (as $PREFIX/bin is the default place to install the command). Abigail
Re: Expected Config File Locations
On 30 August 2011 16:25, Smylers wrote: > On Windows, it uses %LOCAL_APPDATA%\bang.cfg (where %LOCAL_APPDATA% is > gleaned from a system %call). How does that seem to Windows users? > > However it doesn't seem to support recent Windows versions, crashing on. > Windows 7 and even Vista: > > https://rt.cpan.org/Public/Bug/Display.html?id=57625 > http://www.cpantesters.org/cpan/report/7277549 > > You could just call the Win32 API directly to get this directory and then build the dir path. Regards, Peter
Re: Expected Config File Locations
Abigail writes: > On Tue, Aug 30, 2011 at 01:55:48PM +0100, Smylers wrote: > > > Hi. I'm looking for some advice on where I should ... ask users to ... > > put the config file for a command I'm distributing on Cpan. Where > > would you ... expect ... > > it to be? I'm interested in opinions of Windows, Mac, and Unix > > users, for both per-user and system-wide config. Um, sorry for missing words out of my original question. > while directory defaults are found in the current working directory. I hadn't considered directory configuration files. Thanks. > I can only tell you what I would do. Thanks, given that there isn't clearly one right way, opinions are what I'm seeking. > For an application womble, I'd look for $PREFIX/etc/womblerc, and > /etc/womblerc, loading the first one found. The load $HOME/.womblerc > (if exists). Finally, look for ./.womblerc, and load that as well (if > exist). OK. By $PREFIX do you mean the parent directory of where the command is installed -- so /usr/local/bin/womble uses /usr/local/etc/womblerc and /usr/bin/womble uses /usr/etc/womblerc? Thanks. Smylers -- Watch fiendish TV quiz 'Only Connect' (some questions by me) Mondays at 20:30 on BBC4, or iPlayer: http://www.bbc.co.uk/onlyconnect
Re: Expected Config File Locations
David Precious writes: > On Tuesday 30 August 2011 13:55:48 Smylers wrote: > > > Hi. I'm looking for some advice on where I should put the config file > > for a command I'm distributing on Cpan. > > Config::Find looks like it is designed for exactly what you're looking > for - have you seen that? Hi David. Thanks for your reply. For some reason I'd spotted File::ConfigDir but not Config::Find. It looks like it does the right thing on Unix, and its file naming scheme that a command called bang has user config in ~/.bang or ~/.bang.conf is reasonable (though ~/.*.conf doesn't match any files in my home directory). On Windows, it uses %LOCAL_APPDATA%\bang.cfg (where %LOCAL_APPDATA% is gleaned from a system %call). How does that seem to Windows users? However it doesn't seem to support recent Windows versions, crashing on. Windows 7 and even Vista: https://rt.cpan.org/Public/Bug/Display.html?id=57625 http://www.cpantesters.org/cpan/report/7277549 This is particularly irksome since it documents that unsupported Windows versions fall back to generic behaviour, and also because it currently does the same thing on all the editions of Windows that it does support, so distinguishing between them isn't achieving anything. But that's fixable. > It wasn't entirely clear to me whether you're looking for suggestions > on how to *find* the config file in a sensible location, or how to > install a default config file into a suitable location ...? Sorry. It's the former. I want to document where a users should put config files. Thanks. Smylers -- Watch fiendish TV quiz 'Only Connect' (some questions by me) Mondays at 20:30 on BBC4, or iPlayer: http://www.bbc.co.uk/onlyconnect
Re: Expected Config File Locations
Philip Newton writes: > On Tue, Aug 30, 2011 at 14:55, Smylers wrote: > > > I see that psql uses %APPDATA%\postgesql\psqlrc.conf for per-user > > config > > I think that on Windows, the application data directory hierarchy is > the right place for programs to store their own configuration data Hi Philip. Thanks for your reply. > (the exact name of the directory depends on the version of the OS: > it's better to ask the system for the physical path corresponding to > the logical name "foo" than to hard-code the thing). Sure. > On the other hand, that's not a place most people dig around in, > themselves. So if it's a configuration file you expect the user to > edit, then the home directory or a sub directory might be better Yes, that's what I'm dealing with. I want to put in the command's documentation 'instead of providing option --zok in the command line every time, put it in the config file called ...'. Though it seems to me it's also the psql situation. Any Windows psql users here: does the location of psqlrc.conf seem convenient, irritating, or so obscure to you that it's news you could even have such a file? If I do use the home directory, any preferences for the name? > (depending partly on whether you expect to have only one config file > or [potentially] several). I'm sure it'll only be one. (Though I'm guessing when ~/.muttrc and ~/.vimrc were added their developers also thought that ...) > There may be a difference between $HOME (aka %HOME%), > %HOMEDRIVE%%HOMEPATH%, and the home directory you get through a system > call, though I was planning on using File::HomeDir, which seems to've been well researched to DTRT. > > * Most Windows systems seem to be single-user; do I even need both > > system-wide and per-user locations on Windows, and if not which one > > would you expect to find? > > Many programs ask, when they get installed, whether to install it for > "just the current user ($name)" or for "all users". Do Cpan modules? Can I detect which of those was chosen? Thanks. Smylers -- Watch fiendish TV quiz 'Only Connect' (some questions by me) Mondays at 20:30 on BBC4, or iPlayer: http://www.bbc.co.uk/onlyconnect
Re: Expected Config File Locations
On Tue, Aug 30, 2011 at 01:55:48PM +0100, Smylers wrote: > Hi. I'm looking for some advice on where I should put the config file > for a command I'm distributing on Cpan. Where would you it to be? I'm > interested in opinions of Windows, Mac, and Unix users, for both > per-user and system-wide config. > > Or has anybody here dealt with this in Perl, for a command which comes > with a Cpan module and could be installed on any OS where Perl runs? > File::ConfigDir looks like it should be useful for this. I think I'd > want the system_cfg_dir and user_cfg_dir functions (my command doesn't > have a graphical interface, so I don't think it counts as a 'desktop > application') -- do these seem plausible for your platform? > > In particular, on Windows: > > * system_cfg_dir returns the value of %windir%. Is %windir%\bang* a > sensible place for the config of a command called bang? > > * user_cfg_dir returns the user's home directory. Is that a sensible > place for a configuration file? > > I see that psql uses %APPDATA%\postgesql\psqlrc.conf for per-user > config -- is that better? > > * What name would you expect the file to have? Unix has the convention > of a leading dot, such as .vimrc, to hide the file and prevent it from > cluttering up typical directory listings. I see that Vim uses the name > _vimrc on Windows. > > What about the file extensions? I see .psqlrc on Unix is psqlrc.conf > on Windows; does the .conf help with using a text editor to edit it? > > * Most Windows systems seem to be single-user; do I even need both > system-wide and per-user locations on Windows, and if not which one > would you expect to find? > > And on Unix: > > * system_cfg_dir always returns /etc/. On some Unices such as FreeBSD > I've seen /usr/local/etc/ used for commands that are installed under > /usr/local/. Is that what you'd expect? There's no real standard for Unix - but there are some convention. A convention followed by many applications is that there are different "levels" of configuration: system defaults, user defaults, directory defaults. System defaults are often found in one or more of: /etc/ /etc/system/ /etc/application/ /var/application/ /usr/local/etc/ /opt/etc/ $PREFIX/etc/ (with $PREFIX set at configure time) User defaults are typically found in $HOME, and $HOME/.application/, while directory defaults are found in the current working directory. Now, some applications search a set of directories for configuration files, and load all of them (typically system level first, then user level, then directory level). Others search from most specific to least specific, loading the first they find. And even then, many application allow you to pass a configuration file on the command line. > File::ConfigDir has local_cfg_dir, which returns /usr/local/etc. So I > could use that if the command has been installed in /usr/local/bin/ > and stick with /etc/ otherwise. > > But I'd be surprised to find /usr/local/etc/ being used on Linux. > > * What filename would you expect for a command's configuration file? I'm > used to the "rc" suffix, so .bangrc for a command called bang, but for > many of the common .*rc files the contents are genuine 'run commands'. > For example, .bashrc, .muttrc, and .vimrc all contain commands which > could be typed into the program interactively after starting it. System level configuration files usually do *not* have a leading dot, and many of them do not have an rc suffix. And not everything that is for the form "run commands" ends in rc - .profile and .logout (or there bash equivalents). > That doesn't apply to my command, which isn't interactive, so maybe rc > isn't the best suffix. But there are others like this, such as > .screenrc, .cvsrc, .lynxrc, .offlineimaprc, and .muttprintrc. And many more. > Git has .gitconfig and SSH .ssh/config. MySQL uses .my.cnf. Would > .bangconfig or .bang.cnf be better than .bangrc? > > And on OSX: > > * Is this aspect of the system sufficiently similar to FreeBSD that > whatever is appropriate there would be appropriate on OSX as well? If > not, what's different? > > Thanks for any wisdom you can share. I can only tell you what I would do. For an application womble, I'd look for $PREFIX/etc/womblerc, and /etc/womblerc, loading the first one found. The load $HOME/.womblerc (if exists). Finally, look for ./.womblerc, and load that as well (if exist). Unless of course, the user uses the -f option, which loads configuration from the file(s) given at the command line, ignoring any of the configuration files. Abigail
Re: Expected Config File Locations
On Tuesday 30 August 2011 13:55:48 Smylers wrote: > Hi. I'm looking for some advice on where I should put the config file > for a command I'm distributing on Cpan. Where would you it to be? I'm > interested in opinions of Windows, Mac, and Unix users, for both > per-user and system-wide config. > Config::Find looks like it is designed for exactly what you're looking for - have you seen that? I was also going to recommend Config::Auto (which even parses the config, supporting various formats), but it seems to be Unix-centric, and likely not useful on Windows. It wasn't entirely clear to me whether you're looking for suggestions on how to *find* the config file in a sensible location, or how to install a default config file into a suitable location as the module is installed, though - have I got the wrong end of the stick here? -- David Precious ("bigpresh") http://www.preshweb.co.uk/ "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
Re: Expected Config File Locations
On Tue, Aug 30, 2011 at 14:55, Smylers wrote: > In particular, on Windows: > > * system_cfg_dir returns the value of %windir%. Is %windir%\bang* a > sensible place for the config of a command called bang? > > * user_cfg_dir returns the user's home directory. Is that a sensible > place for a configuration file? > > I see that psql uses %APPDATA%\postgesql\psqlrc.conf for per-user > config -- is that better? I think that on Windows, the application data directory hierarchy is the right place for programs to store their own configuration data (the exact name of the directory depends on the version of the OS: it's better to ask the system for the physical path corresponding to the logical name "foo" than to hard-code the thing). You even get to choose whether those settings are machine-specific (things like caches) or not (settings a user might expect to find even if he logs in with his account somewhere else, if his account is shared across/available through multiple machines): you have AppData/Local or AppData/Roaming. (Again, exact names vary.) On the other hand, that's not a place most people dig around in, themselves. So if it's a configuration file you expect the user to edit, then the home directory or a sub directory might be better (depending partly on whether you expect to have only one config file or [potentially] several). There may be a difference between $HOME (aka %HOME%), %HOMEDRIVE%%HOMEPATH%, and the home directory you get through a system call, though > * Most Windows systems seem to be single-user; do I even need both > system-wide and per-user locations on Windows, and if not which one > would you expect to find? Many programs ask, when they get installed, whether to install it for "just the current user ($name)" or for "all users". Cheers, Philip -- Philip Newton
Expected Config File Locations
Hi. I'm looking for some advice on where I should put the config file for a command I'm distributing on Cpan. Where would you it to be? I'm interested in opinions of Windows, Mac, and Unix users, for both per-user and system-wide config. Or has anybody here dealt with this in Perl, for a command which comes with a Cpan module and could be installed on any OS where Perl runs? File::ConfigDir looks like it should be useful for this. I think I'd want the system_cfg_dir and user_cfg_dir functions (my command doesn't have a graphical interface, so I don't think it counts as a 'desktop application') -- do these seem plausible for your platform? In particular, on Windows: * system_cfg_dir returns the value of %windir%. Is %windir%\bang* a sensible place for the config of a command called bang? * user_cfg_dir returns the user's home directory. Is that a sensible place for a configuration file? I see that psql uses %APPDATA%\postgesql\psqlrc.conf for per-user config -- is that better? * What name would you expect the file to have? Unix has the convention of a leading dot, such as .vimrc, to hide the file and prevent it from cluttering up typical directory listings. I see that Vim uses the name _vimrc on Windows. What about the file extensions? I see .psqlrc on Unix is psqlrc.conf on Windows; does the .conf help with using a text editor to edit it? * Most Windows systems seem to be single-user; do I even need both system-wide and per-user locations on Windows, and if not which one would you expect to find? And on Unix: * system_cfg_dir always returns /etc/. On some Unices such as FreeBSD I've seen /usr/local/etc/ used for commands that are installed under /usr/local/. Is that what you'd expect? File::ConfigDir has local_cfg_dir, which returns /usr/local/etc. So I could use that if the command has been installed in /usr/local/bin/ and stick with /etc/ otherwise. But I'd be surprised to find /usr/local/etc/ being used on Linux. * What filename would you expect for a command's configuration file? I'm used to the "rc" suffix, so .bangrc for a command called bang, but for many of the common .*rc files the contents are genuine 'run commands'. For example, .bashrc, .muttrc, and .vimrc all contain commands which could be typed into the program interactively after starting it. That doesn't apply to my command, which isn't interactive, so maybe rc isn't the best suffix. But there are others like this, such as .screenrc, .cvsrc, .lynxrc, .offlineimaprc, and .muttprintrc. Git has .gitconfig and SSH .ssh/config. MySQL uses .my.cnf. Would .bangconfig or .bang.cnf be better than .bangrc? And on OSX: * Is this aspect of the system sufficiently similar to FreeBSD that whatever is appropriate there would be appropriate on OSX as well? If not, what's different? Thanks for any wisdom you can share. Smylers -- Watch fiendish TV quiz 'Only Connect' (some questions by me) Mondays at 20:30 on BBC4, or iPlayer: http://www.bbc.co.uk/onlyconnect