BugOptions - cannot locate settings folder.

@khaneagles: If I rename the mod folder of my own copy of BUG 4.4, then the mod still seems to be able to locate the UserSettings folder inside the mod folder; no error messages. I assume that you have the folder in the same place? Maybe it's a permission issue then. You could try changing the access rights or moving the folder to My Games\Beyond the Sword\{modName}. Also seems worth a try to change the modName variable in CvModName.py to HakanMod. As mwonch wrote:
Apparently, most mods/merged components do not require this file to properly reflect the mod being used - this one does. So, if all folders and files other than those changed are the same, this error could possible be caused by the above file containing the wrong mod name.
 
I change "the modName variable in CvModName.py to HakanMod" but "cannot locate settings folder" warning and also saving problem still continue...
I also try to "run as adminstration" and giving permission all folder but the same problems still continue...
I don't understand "you have the folder in the same place"? Because my bug mod folder is in "My Documents\My Games\Beyond the Sword", my mod is in BTS game folder (D:\Games\Civ 4\BTS\Mods)...

My folders were like this when I used to play. I used to use win10, but now I'm using win11.
As far as I understand, if I can solve the "cannot locate settings folder" problem, there will be no problem. Because I didn't have such a problem before in my old saved game, this problem appeared when I saved the game again and also reloaded it...
 
Because my bug mod folder is in "My Documents\My Games\Beyond the Sword", my mod is in BTS game folder (D:\Games\Civ 4\BTS\Mods)...
So it's D:\Games\Civ 4\BTS\Mods\HakanMod, I assume, and that's the mod you're loading. And it includes BUG, i.e. all of BUG's Python scripts and other assets? I guess it has to, unless BUG is getting loaded from My Games\Beyond the Sword\CustomAssets. But it sounds to me like My Games\Beyond the Sword only contains the BUG settings folder with the ini files, i.e. the very folder that BUG is unable to locate.
I don't understand "you have the folder in the same place"?
Seems that we do not have it in the same location. Though I also have several BUG-based mods installed that keep their BUG settings under My Games.

Perhaps a little more logging will make clearer where things go wrong (my additions are only the print statements):
Spoiler :
Code:
def initDataFolder():
	"""
	Finds the first directory that contains a folder named SETTINGS_FOLDER.
	"""
	global _dataFolderInitDone
	if _dataFolderInitDone:
		return
	BugUtil.debug("BugPath - initializing data folder")
	
	dataDirs = (
		join(getUserDir(), getModName()),	# My Games\BUG Mod
		join(getRootDir(), getModName()),	# My Games\BTS\BUG Mod
		join(getAppDir(), getModName()),	 # Civ4\BTS\BUG Mod
		join(getModDir(), DATA_FOLDER),	  # Civ4\BTS\Mods\BUG Mod 3.6\Data
		join(getModDir()),				   # Civ4\BTS\Mods\BUG Mod 3.6
	)
	print "Settings folder name: " + SETTINGS_FOLDER
	for dir in dataDirs:
		print dir
		if setDataDir(dir):
			print "DataDir set"
			break
		else:
			print "Failed to set DataDir"
	else:
		BugUtil.error("No valid data directory containing %s found", SETTINGS_FOLDER)
	_dataFolderInitDone = True
If I start a new game with my own fork of BUG/BULL, named "Taurus", I get the following relevant output in PythonDbg.log (with some notes added in square brackets):
Spoiler :
Code:
DEBUG: BugPath - CvAltRoot module not present
DEBUG: BugPath - Checking user dir 'C:\Users\Administrator\Documents\My Games'
INFO : BugPath - user dir is 'C:\Users\Administrator\Documents\My Games'
INFO : BugPath - found valid Windows XP My Documents folder registry key
DEBUG: BugPath - Checking root dir 'C:\Users\Administrator\Documents\My Games\Beyond the Sword'
INFO : BugPath - root dir is 'C:\Users\Administrator\Documents\My Games\Beyond the Sword'
DEBUG: BugPath - initializing data folder
Settings folder name: UserSettings

C:\Users\Administrator\Documents\My Games\Taurus
Failed to set DataDir
C:\Users\Administrator\Documents\My Games\Beyond the Sword\Taurus
Failed to set DataDir
[Yup, no "Taurus" folder under My Games.]

C:\Program Files (x86)\Sid Meier's Civilization 4\Beyond the Sword\Taurus
Failed to set DataDir
[Also correct. I don't think anyone would put their files directly in the BtS install directory.]

C:\Program Files (x86)\Sid Meier's Civilization 4\Beyond the Sword\Mods\Taurus\Data
Failed to set DataDir
[The Taurus folder exists, but there is no Data subfolder.]

C:\Program Files (x86)\Sid Meier's Civilization 4\Beyond the Sword\Mods\Taurus
12:24:34 DEBUG: BugPath - Checking data dir 'C:\Program Files (x86)\Sid Meier's Civilization 4\Beyond the Sword\Mods\Taurus'
12:24:34 INFO : BugPath - data dir is 'C:\Program Files (x86)\Sid Meier's Civilization 4\Beyond the Sword\Mods\Taurus'
DataDir set
[That's where my UserSettings folder is and BUG manages to locate it.]
My folders were like this when I used to play. I used to use win10, but now I'm using win11.
As far as I understand, if I can solve the "cannot locate settings folder" problem, there will be no problem. Because I didn't have such a problem before in my old saved game, this problem appeared when I saved the game again and also reloaded it...
I don't think I can identify the problem just based on that background, but it's good to know.
 
This here ...
Code:
INFO : BugPath - found valid Windows XP My Documents folder registry key
... could perhaps go wrong on Win 11. Might not be able to find "My Documents". This is the code for the registry lookup (BugPath.py):
Spoiler :
Code:
		# Windows
		import _winreg
		def getRegValue(root, subkey, name):
			key = _winreg.OpenKey(root, subkey)
			try:
				value = _winreg.QueryValueEx(key, name)
				return value[0]
			finally:
				key.Close()
		
		for version, key, subkey in MY_DOCUMENTS_FOLDER_REG_KEYS:
			try:
				myDocuments = getRegValue(_winreg.HKEY_CURRENT_USER, key, subkey)
			except:
				pass
			else:
				if setUserDir(join(myDocuments, MY_GAMES_FOLDER)):
					safeInfoPath("BugPath - found valid Windows %s My Documents folder registry key", version)
					break
		else:
			BugUtil.debug("BugPath - no valid My Documents registry key")
And near the top:
Code:
MY_DOCUMENTS_FOLDER_REG_KEYS = (
	("XP", r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Personal"),
	("Vista", r"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal"),
)
MY_GAMES_FOLDER = "My Games"
Well, the log output (with LoggingEnabled=1 in CivilizationIV.ini) should clarify if that's the issue.
 
## <user-dir>\<mod-name> C:\Users\HakanKartal\Documents\My Games\Beyond the Sword\BUG Mod
## <root-dir>\<mod-name> C:\Users\HakanKartal\Documents\My Games\Beyond the Sword\BUG Mod
## <app-dir>\<mod-name> C:\Users\HakanKartal\Documents\My Games\Beyond the Sword\BUG Mod
## <mod-dir>\<data-folder> C:\Programs\Sid Meier's Civilization IV\Beyond the Sword\Mods\BUG Mod x.x\Data
## <mod-dir> C:\Programs\Sid Meier's Civilization IV\Beyond the Sword\Mods\BUG Mod x.x
I change user-dir, root-dir and app-dir because there were wrong shortcuts here. I try again but problem continues.
And also i control bugpath.py just like your but they are all the same as the one you sent...
MY_DOCUMENTS_FOLDER_REG_KEYS = (
("XP", r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Personal"),
("Vista", r"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal"),
)
MY_GAMES_FOLDER = "My Games"
# Windows
import _winreg
def getRegValue(root, subkey, name):
key = _winreg.OpenKey(root, subkey)
try:
value = _winreg.QueryValueEx(key, name)
return value[0]
finally:
key.Close()

for version, key, subkey in MY_DOCUMENTS_FOLDER_REG_KEYS:
try:
myDocuments = getRegValue(_winreg.HKEY_CURRENT_USER, key, subkey)
except:
pass
else:
if setUserDir(join(myDocuments, MY_GAMES_FOLDER)):
safeInfoPath("BugPath - found valid Windows %s My Documents folder registry key", version)
break
else:
BugUtil.debug("BugPath - no valid My Documents registry key")
def initDataFolder():
"""
Finds the first directory that contains a folder named SETTINGS_FOLDER.
"""
global _dataFolderInitDone
if _dataFolderInitDone:
return
BugUtil.debug("BugPath - initializing data folder")

dataDirs = (
join(getUserDir(), getModName()), # My Games\BUG Mod
join(getRootDir(), getModName()), # My Games\BTS\BUG Mod
join(getAppDir(), getModName()), # Civ4\BTS\BUG Mod
join(getModDir(), DATA_FOLDER), # Civ4\BTS\Mods\BUG Mod 3.6\Data
join(getModDir()), # Civ4\BTS\Mods\BUG Mod 3.6
)
print "Settings folder name: " + SETTINGS_FOLDER
for dir in dataDirs:
print dir
if setDataDir(dir):
print "DataDir set"
break
else:
print "Failed to set DataDir"
else:
BugUtil.error("No valid data directory containing %s found", SETTINGS_FOLDER)
_dataFolderInitDone = True
And also "LoggingEnabled=1" in CivilizationIV.ini. I'm going really crazy...
 
I change user-dir, root-dir and app-dir because there were wrong shortcuts here. I try again but problem continues.
Changed them ... in the comments? That's not going to affect the program behavior and the paths there are just meant as examples.
And also i control bugpath.py just like your but they are all the same as the one you sent...
Right, I didn't change anything in the registry-related code, and the print statements I added are only for additional diagnostics. Did you check PythonDbg.log (My Games\Beyond the Sword\Logs)? That file should show the paths under which BUG looks for the settings.
 
Changed them ... in the comments? That's not going to affect the program behavior and the paths there are just meant as examples.
Right, I didn't change anything in the registry-related code, and the print statements I added are only for additional diagnostics. Did you check PythonDbg.log (My Games\Beyond the Sword\Logs)? That file should show the paths under which BUG looks for the settings.
Before, there seemed to be a different path... For example C:\Users\Users\Documents\My Games\BUG Mod. So I thought the error was caused by this. But you are right, nothing is changed.

I don't know what exactly do I need to look for pythonDbg.log?
 
You could attach the whole thing (with .txt file ending or zipped). I think the interesting part will be what I posted from my own PythonDbg.log, i.e. starting at "DEBUG: BugPath - CvAltRoot module not present" up to (including) the "Failed to set DataDir" messages. Though, ultimately, only you could say which of the paths in the log look wrong – or if the correct path to your BUG settings is actually being checked.
 
18:13:48 DEBUG: BugPath - CvAltRoot module not present
load_module _winreg

18:13:48 DEBUG: BugPath - Checking user dir 'C:\Users\Anil\Documents\My Games'
18:13:48 DEBUG: BugPath - Checking user dir 'USERPROFILE\Documents\My Games'
18:13:48 DEBUG: BugPath - no valid My Documents registry key
18:13:48 ERROR: Cannot find CivilizationIV.ini; see Info/CvAltRoot.py for instructions
18:13:48 DEBUG: BugPath - initializing data folder
Settings folder name: UserSettings

None

Failed to set DataDir
Hello again and please excuse the delayed reply. When I look at the place you mentioned, I see that the place 'C:\Users\Anil\Documents\My Games' is wrong, I need to change it to 'C:\Users\HakanKartal\Documents\My Games'. Apart from this, do you think there is anything else I should do?
 
I wonder how it gets the "Users" path – since it also says that no "My Documents" registry key was found. Well, maybe it's not necessary to figure that out. I would try either moving UserSettings into your HakanMod folder – that is:
my mod is in BTS game folder (D:\Games\Civ 4\BTS\Mods)...
–; or moving CvAltRoot.py from the Info folder into Assets\Python and specifying the "My Documents" path in CvAltRoot.py (all according to the comments in that file).

I assume that the HakanMod path appears a bit farther down below in PythonDbg.log, i.e. that BUG will check for UserSettings there. As for having UserSettings under My Documents, maybe BUG generally can't find My Documents on Win 11, or perhaps just not on your particular version of that OS. Or did you possibly just copy the BtS files from an earlier installation instead of running the installer? That would also explain why no registry keys can be found.
 
I wonder how it gets the "Users" path – since it also says that no "My Documents" registry key was found. Well, maybe it's not necessary to figure that out. I would try either moving UserSettings into your HakanMod folder – that is: –; or moving CvAltRoot.py from the Info folder into Assets\Python and specifying the "My Documents" path in CvAltRoot.py (all according to the comments in that file).

I assume that the HakanMod path appears a bit farther down below in PythonDbg.log, i.e. that BUG will check for UserSettings there. As for having UserSettings under My Documents, maybe BUG generally can't find My Documents on Win 11, or perhaps just not on your particular version of that OS. Or did you possibly just copy the BtS files from an earlier installation instead of running the installer? That would also explain why no registry keys can be found.
As you said, I moved the "UserSettings" folder to the HakanMod folder. Then I moved the cvaltroot.py file to the CustomAssets/Python folder, but the same problem still persists.
By the way, no, I installed BTS from scratch, I did not copy it in any way.
 
:( What does PythonDbg.log say now? Would be interesting to see the CvAltRoot and "user dir" mentions, but also all the "Failed to set DataDir" messages.
 
Last edited:
:( What does PythonDbg.log say now? Would be interesting to see the CvAltRoot and "user dir" mentions, but also all the "Failed to set DataDir" messages.
I am attaching the pythondbg file for both processes. "1" is the post-processing of the "User Settings" folder in the HakanMod folder, "2" is the post-processing after moving the CvAltRoot.py file to the CustomAssets folder... If there is any file you want me to add, I can add it too.
 
I am attaching the pythondbg file for both processes. "1" is the post-processing of the "User Settings" folder in the HakanMod folder, "2" is the post-processing after moving the CvAltRoot.py file to the CustomAssets folder... If there is any file you want me to add, I can add it too.
13:47:19 INFO : BugPath - NoCustomAssets is False
13:47:19 DEBUG: BugPath - initializing system folders
load_module CvAltRoot

CvAltRoot

import failed

13:47:19 DEBUG: BugPath - CvAltRoot module not present
load_module _winreg

13:47:19 DEBUG: BugPath - Checking user dir 'C:\Users\Anil\Documents\My Games'
13:47:19 DEBUG: BugPath - Checking user dir 'USERPROFILE\Documents\My Games'
13:47:19 DEBUG: BugPath - no valid My Documents registry key
13:47:19 ERROR: Cannot find CivilizationIV.ini; see Info/CvAltRoot.py for instructions
13:47:19 DEBUG: BugPath - initializing data folder
Settings folder name: UserSettings

None

Failed to set DataDir

None

Failed to set DataDir

D:\Oyunlar\CIV 4\Beyond the Sword\BUG Mod

Failed to set DataDir

D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod\Data

Failed to set DataDir

D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod

13:47:19 DEBUG: BugPath - Checking data dir 'D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod'
Failed to set DataDir

13:47:19 ERROR: No valid data directory containing UserSettings found
13:49:21 INFO : BugPath - NoCustomAssets is False
13:49:21 DEBUG: BugPath - initializing system folders
load_module CvAltRoot

13:49:21 DEBUG: BugPath - Checking root dir 'C:/Documents and Settings/HakanKartal/My Documents/My Games/Beyond the Sword'
13:49:21 ERROR: Directory from CvAltRoot.py is not valid or does not contain CivilizationIV.ini
load_module _winreg

13:49:21 DEBUG: BugPath - Checking user dir 'C:\Users\Anil\Documents\My Games'
13:49:21 DEBUG: BugPath - Checking user dir 'USERPROFILE\Documents\My Games'
13:49:21 DEBUG: BugPath - no valid My Documents registry key
13:49:21 ERROR: Cannot find CivilizationIV.ini; see Info/CvAltRoot.py for instructions
13:49:21 DEBUG: BugPath - initializing data folder
Settings folder name: UserSettings

None

Failed to set DataDir

None

Failed to set DataDir

D:\Oyunlar\CIV 4\Beyond the Sword\BUG Mod

Failed to set DataDir

D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod\Data

Failed to set DataDir

D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod

13:49:21 DEBUG: BugPath - Checking data dir 'D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod'
Failed to set DataDir

13:49:21 ERROR: No valid data directory containing UserSettings found
 
Thanks. The first one says
Code:
DEBUG: BugPath - Checking data dir 'D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod'
Failed to set DataDir
ERROR: No valid data directory containing UserSettings found
... the second:
Code:
load_module CvAltRoot
Checking root dir 'C:/Documents and Settings/HakanKartal/My Documents/My Games/Beyond the Sword'
ERROR: Directory from CvAltRoot.py is not valid or does not contain CivilizationIV.ini
Those are the errors I didn't expect to see.

This is the setDataDir function (BugPath.py):
Spoiler :
Code:
def setDataDir(dir):
	if isdir(dir):
		safeDebugPath("BugPath - Checking data dir '%s'", dir)
		settingsDir = join(dir, SETTINGS_FOLDER)
		if isdir(settingsDir):
			safeInfoPath("BugPath - data dir is '%s'", dir)
			global _dataDir, _settingsDir, _infoDir
			_dataDir = dir
			_settingsDir = settingsDir
			_infoDir = join(dir, INFO_FOLDER)
			BugConfigTracker.add("Settings_Directory", _settingsDir)
			return True
	return False
In your first log, the "Checking data dir" message appears, so, apparently, "D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod" exists and can be accessed. The "data dir is" message does not appear, so "D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod\UserSettings" is not found or can't be accessed. I doubt that permissions could be the problem when the code only tries to test whether the folder exists. So this is strange; I don't see what more you can do - assuming that UserSettings had indeed been present in that location. Maybe creating a new, empty UserSettings folder is worth a shot. I'd expect such a folder to inherit the access rights of its enclosing folder (HakanMod - which BUG does manage to access).

As for the second attempt, setRootDir is the relevant function:
Spoiler :
Code:
def setRootDir(dir):
	safeDebugPath("BugPath - Checking root dir '%s'", dir)
	if isdir(dir) and isfile(join(dir, "CivilizationIV.ini")):
		global _rootDir
		_rootDir = dir
		safeInfoPath("BugPath - root dir is '%s'", dir)
		BugConfigTracker.add("Root_Directory", _rootDir)
		return True
	return False
The "Checking root dir" message appears, so setRootDir is getting called with the path that you've entered into CvAltRoot.py. The path uses slashes instead of backslashes, but I can't imagine that that's a problem; the example in the original file also uses slashes. Still, either the isdir check or the isfile check fails. Just to make sure: "C:/Documents and Settings/HakanKartal/My Documents/My Games/Beyond the Sword/CivilizationIV.ini" does exist on your system? (It looks plausible ...) Again, just checking whether files and folders exist should hardly require elevated permissions; ... but perhaps it does. :undecide:
 
Thanks. The first one says
Code:
DEBUG: BugPath - Checking data dir 'D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod'
Failed to set DataDir
ERROR: No valid data directory containing UserSettings found
... the second:
Code:
load_module CvAltRoot
Checking root dir 'C:/Documents and Settings/HakanKartal/My Documents/My Games/Beyond the Sword'
ERROR: Directory from CvAltRoot.py is not valid or does not contain CivilizationIV.ini
Those are the errors I didn't expect to see.

This is the setDataDir function (BugPath.py):
Spoiler :
Code:
def setDataDir(dir):
    if isdir(dir):
        safeDebugPath("BugPath - Checking data dir '%s'", dir)
        settingsDir = join(dir, SETTINGS_FOLDER)
        if isdir(settingsDir):
            safeInfoPath("BugPath - data dir is '%s'", dir)
            global _dataDir, _settingsDir, _infoDir
            _dataDir = dir
            _settingsDir = settingsDir
            _infoDir = join(dir, INFO_FOLDER)
            BugConfigTracker.add("Settings_Directory", _settingsDir)
            return True
    return False
In your first log, the "Checking data dir" message appears, so, apparently, "D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod" exists and can be accessed. The "data dir is" message does not appear, so "D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod\UserSettings" is not found or can't be accessed. I doubt that permissions could be the problem when the code only tries to test whether the folder exists. So this is strange; I don't see what more you can do - assuming that UserSettings had indeed been present in that location. Maybe creating a new, empty UserSettings folder is worth a shot. I'd expect such a folder to inherit the access rights of its enclosing folder (HakanMod - which BUG does manage to access).

As for the second attempt, setRootDir is the relevant function:
Spoiler :
Code:
def setRootDir(dir):
    safeDebugPath("BugPath - Checking root dir '%s'", dir)
    if isdir(dir) and isfile(join(dir, "CivilizationIV.ini")):
        global _rootDir
        _rootDir = dir
        safeInfoPath("BugPath - root dir is '%s'", dir)
        BugConfigTracker.add("Root_Directory", _rootDir)
        return True
    return False
The "Checking root dir" message appears, so setRootDir is getting called with the path that you've entered into CvAltRoot.py. The path uses slashes instead of backslashes, but I can't imagine that that's a problem; the example in the original file also uses slashes. Still, either the isdir check or the isfile check fails. Just to make sure: "C:/Documents and Settings/HakanKartal/My Documents/My Games/Beyond the Sword/CivilizationIV.ini" does exist on your system? (It looks plausible ...) Again, just checking whether files and folders exist should hardly require elevated permissions; ... but perhaps it does. :undecide:
Yes, civilization.ini files in the "C:\Users\HakanKartal\Documents\My Games\Beyond the Sword".
Do you have any suggestions I can make as a result? Or should I use it this way? It's just that I always remember that there is no folder called "C:\Users\Anil\Documents\My Games"; As I said before, BugMod is in the "C:\Users\HakanKartal\Documents\My Games" folder. But it always looks like this in bugpath.py, even if I want to change it, it still appears the same way. Could this be the source of the error?
By the way, I completely deleted the game and reinstalled it (including the logbooks), but it still gives the same error.
 
Yes, civilization.ini files in the "C:\Users\HakanKartal\Documents\My Games\Beyond the Sword".
Just to make sure: "C:/Documents and Settings/HakanKartal/My Documents/My Games/Beyond the Sword/CivilizationIV.ini" does exist on your system?
Those aren't quite the same. Looks to me like you've kept part of the path given as an example in CvAltRoot.py. I'd try
Code:
rootDir = "C:/Users/HakanKartal/Documents/My Games/Beyond the Sword"
That's with UserSettings under My Games where you've had them all along. And as for the approach with UserSettings in
Code:
DEBUG: BugPath - Checking data dir 'D:\Oyunlar\CIV 4\Beyond the Sword\Mods\HakanMod'
as I wrote, just creating an empty UserSettings folder there could be worth a try.
Do you have any suggestions I can make as a result? Or should I use it this way?
I still feel that it should be possible to narrow the issue down. E.g. if isdir really fails for one folder and succeeds for another, how do their properties differ ... As a last resort, you could change some of the BUG default settings through the XML files in the Config folder. That way, when BUG can't find the UserSettings, it'll apply the settings that you want through the default settings.
It's just that I always remember that there is no folder called "C:\Users\Anil\Documents\My Games" [...]
Yes, that's another angle to investigate. The messages ...
Code:
load_module _winreg
DEBUG: BugPath - Checking user dir 'C:\Users\Anil\Documents\My Games'
DEBUG: BugPath - Checking user dir 'USERPROFILE\Documents\My Games'
DEBUG: BugPath - no valid My Documents registry key
seem to originate here:
Spoiler :
Code:
		# Windows
		import _winreg
		def getRegValue(root, subkey, name):
			key = _winreg.OpenKey(root, subkey)
			try:
				value = _winreg.QueryValueEx(key, name)
				return value[0]
			finally:
				key.Close()
		
		for version, key, subkey in MY_DOCUMENTS_FOLDER_REG_KEYS:
			try:
				myDocuments = getRegValue(_winreg.HKEY_CURRENT_USER, key, subkey)
			except:
				pass
			else:
				if setUserDir(join(myDocuments, MY_GAMES_FOLDER)):
					safeInfoPath("BugPath - found valid Windows %s My Documents folder registry key", version)
					break
		else:
			BugUtil.debug("BugPath - no valid My Documents registry key")
So, winreg gets loaded. And in the end there's "no valid My Documents registry key." However, it seems that the Anil path is in fact obtained from the registry; it just isn't a valid path. Could be leftovers from earlier installations that a fresh install doesn't necessarily remove. The registry keys in question are:
Spoiler :
Code:
MY_DOCUMENTS_FOLDER_REG_KEYS = (
	("XP", r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Personal"),
	("Vista", r"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal"),
)
BUG doesn't check whether the OS is indeed "XP" or "Vista". It looks for those keys under HKEY_CURRENT_USER. Maybe you could use regedit (if that's still a thing on Win 11) to take a look at "Shell Folders" or "User Shell Folders" under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer in the registry. Maybe there is indeed a key named "Personal" that contains an outdated path (which could then also be corrected inside regedit).

Edit: I do have that "Personal" key on my Windows 8 system. I'm attaching a screenshot. That %USERPROFILE% variable seems to work correctly for me; in PythonDbg.log, I get: "found valid Windows XP My Documents folder registry key".
 

Attachments

  • regedit.jpg
    regedit.jpg
    477.9 KB · Views: 9
Last edited:
2024-06-09.png

As you said, when I look at regedit, it appears as "personal" as C:\Users\Anil\Documents. So is this the problem?
 
I assume that, if "Personal" did point to your current My Games folder, BUG would find the UserSettings. But changing it in the registry is perhaps not a good idea after all. Who knows how that will affect other programs that might access that registry key. Well, I guess changing a path that doesn't exist to one that does exist won't do harm, could even fix issues with other programs. :think: Maybe there is a remote possibility of user data getting deleted when the "Personal" key is changed.

I see that there's also "User Shell Folders" in your screenshot. BUG should check that one as well once the path from "Shell Folders" has failed. Maybe it's just the same path (/Anil/) again. It would be reassuring to understand why these paths are incorrect. A quick Google search suggests to me that they're still in use under Win 11, not just for backwards compatibility with old software. Here's a guide, for example, for restoring sensible paths after some mishap with OneDrive. The safer, easier way to fix only the BUG issue should be CvAltRoot.py.
 
Hello again. I change Personal/Shell Folders "C:\Users\Anil\Documents" and so the "cannot locate settings folder" error no longer exists. :king:
You both made time for me and guided me. Thank you for everything. :thanx:

 
Back
Top Bottom