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

Config file location on Windows #242

Closed
grawity opened this issue Dec 3, 2011 · 15 comments
Closed

Config file location on Windows #242

grawity opened this issue Dec 3, 2011 · 15 comments

Comments

@grawity
Copy link
Contributor

@grawity grawity commented Dec 3, 2011

Currently, youtube-dl uses Unix-specific locations (XDG_CONFIG_HOME) for finding the configuration files. On Windows, "Application Data" is a better location for this, and the proper way to find it is by using SHGetFolderPath(), as in this example.

(Windows also provides os.environ["APPDATA"], but this is somewhat less reliable, and does not exist in some uncommon situations.)

@phihag
Copy link
Contributor

@phihag phihag commented Dec 6, 2011

Note that even on Windows, we should fall back to C:/Users/grawity/.config/youtube-dl.conf. But you're right, that location is not optimal.

@ghost ghost assigned phihag Dec 8, 2011
@phihag
Copy link
Contributor

@phihag phihag commented Dec 8, 2011

I have two questions:

  1. What should the data structure inside the directory look like? Should we just place a youtube-dl.conf in there? Is there any guideline by Microsoft?
  2. What is the reason for not using SHGetKnownFolderPath?
@grawity
Copy link
Contributor Author

@grawity grawity commented Dec 10, 2011

@phihag,

What should the data structure inside the directory look like? Should we just place a youtube-dl.conf in there? Is there any guideline by Microsoft?

Most programs create their own directory directly under AppData – for example, AppData\youtube-dl or AppData\Dropbox.

A slightly less common hierarchy is AppData<i>author<i>program, for example, AppData\rg3\youtube-dl or AppData\Mozilla\Firefox.

Finally, some just use AppData<i>author; for example, AppData\rg3 or AppData\Ghisler\wincmd.ini.

I would choose either 1) or 3) for youtube-dl. Using 2) is okay but a little too verbose, seeing that you only have one program with one config file. In the end, anything is okay as long as it's tidy.

Edit: As for official guidelines, I've found a MSDN section "Windows 2000 Application Specifications", whose section 4 describes application data storage. It suggests AppData\author\program\version, but that is very rarely necessary and I've only seen Adobe Reader and Microsoft Office follow this hierarchy.

Note: Even on Unix, all programs using XDG_CONFIG_HOME use a separate subdirectory – for example, ~/.config/youtube-dl/youtube-dl.conf, files are almost never placed directly under ~/.config.

What is the reason for not using SHGetKnownFolderPath?

This function was only introduced in Windows Vista, as its MSDN doc page says. In contrast, SHGetFolderPath has been available since Windows 2000, and is unlikely to disappear – Microsoft has a strict policy of never removing documented APIs (or, I would assume, making incompatible changes to them). Using both functions depending on the OS version would only lead to code duplication with no increase in functionality.

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Jan 26, 2015

youtube-dl uses now %APPDATA%\youtube-dl\config.txt or C:\Users\<user name>\youtube-dl.conf see the README. So I'm closing the issue. If you think it should be reopen, please comment here. Thanks for the report!

@jaimeMF jaimeMF closed this Jan 26, 2015
@dogancelik
Copy link

@dogancelik dogancelik commented Nov 12, 2017

C:\Users\<user name>\youtube-dl.conf is not working but %APPDATA% method works, can you look at this issue?

@Hrxn
Copy link

@Hrxn Hrxn commented Nov 13, 2017

I've been using C:\Users\<user>\youtube-dl.conf since forever, and it never failed.

Are you absolutely positive that the filename is youtube-dl.conf, and not youtube-dl.conf.txt etc.?
Or maybe some unsupported char symbol as Username?

@dogancelik
Copy link

@dogancelik dogancelik commented Nov 13, 2017

Yes absolutely positive, I tested

conf1

@photonometric
Copy link

@photonometric photonometric commented Apr 2, 2018

Personally I put my "portable" programs in a custom high-level folder because the User and Appdata folders are awkward to use. I think the configuration file should be allowed in the program directory; your reference to standard locations is very well thought out, but the vast majority of "project" software like this keep their config.ini folder in the program directory. It's where I have to go to run the program, and I won't lose it if I move the program/reformat/etc and forget its config is in an arbitrary separate location. Large/complex software like MS Office or Firefox seems to be more what separate Appdata or user-folder configs is best for.

tldr it would be nice if the file would be recognized in the program's own folder, whether config.txt, youtube-dl.conf, or the more traditional config.ini :)

@canklot
Copy link

@canklot canklot commented Oct 23, 2018

Does config file created by default ? Or is it created after a commands in youtube dl ?

@Hrxn
Copy link

@Hrxn Hrxn commented Oct 23, 2018

You have to create that file manually..

@Naomi010Sentzke
Copy link

@Naomi010Sentzke Naomi010Sentzke commented Feb 24, 2020

Still no way to have a global system wide config file in Windows

@Guillaume-Garrigos
Copy link

@Guillaume-Garrigos Guillaume-Garrigos commented Apr 7, 2020

I don't know if this may help somebody, but I tried to put the config file in
%APPDATA%\youtube-dl\config.txt
and it did not work. Though, this location seemed strange to me since on my computer (xps 13, Win10) the configuration/profile files are stored in subfolders of AppData, usually in Roaming. So I did instead

C:\Users\MyUserName\AppData\Roaming\youtube-dl\config.txt

and it works as intended.

@Hrxn
Copy link

@Hrxn Hrxn commented Apr 7, 2020

This should be the same path, actually.

@Guillaume-Garrigos
Copy link

@Guillaume-Garrigos Guillaume-Garrigos commented Apr 7, 2020

Ohh I understand now. %APPDATA% is a shortcut for
C:\Users\MyUserName\AppData\Roaming
and not
C:\Users\MyUserName\AppData\

Thanks for the hint.

@Hrxn
Copy link

@Hrxn Hrxn commented Apr 7, 2020

Yep, exactly 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.