Repository: Cog-Creators/Red-DiscordBot

Issue:
Trying to run a red with no instance fails on fresh install
### What Red version are you using?

3.4.14

### What were you trying to do?

Trying to run an red without an instance since I'm lazy and wanted to test something and call it a day.

### What did you expect to happen?

Start the red normally without an instance

### What actually happened?

Getting this if i do `redbot --no-instance --token TOKEN --prefix ~ --owner MY ID` 

```py
Warning: The data will be placed in a temporary folder and removed on next system reboot.
Unexpected exception (<class 'FileNotFoundError'>): 
Traceback (most recent call last):
  File "/Users/kato/Downloads/red/redenv/lib/python3.9/site-packages/redbot/__main__.py", line 503, in main
    data_manager.create_temp_config()
  File "/Users/kato/Downloads/red/redenv/lib/python3.9/site-packages/redbot/core/data_manager.py", line 64, in create_temp_config
    with config_file.open("r", encoding="utf-8") as fs:
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py", line 1242, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py", line 1110, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/kato/Library/Application Support/Red-DiscordBot/config.json'
```

### How can we reproduce this error?

1. Install red in a fresh system (cause didn't happen on my main vps)
2. Do not setup an instance and go to step 3.
3. Start red with `--no-instance` flag

### Anything else?

_No response_


Discussion:

Resolving patch:
diff --git a/redbot/core/data_manager.py b/redbot/core/data_manager.py
--- a/redbot/core/data_manager.py
+++ b/redbot/core/data_manager.py
@@ -46,6 +46,21 @@
 config_file = config_dir / "config.json"
 
 
+def load_existing_config():
+    """Get the contents of the config file, or an empty dictionary if it does not exist.
+
+    Returns
+    -------
+    dict
+        The config data.
+    """
+    if not config_file.exists():
+        return {}
+
+    with config_file.open(encoding="utf-8") as fs:
+        return json.load(fs)
+
+
 def create_temp_config():
     """
     Creates a default instance for Red, so it can be ran
@@ -61,8 +76,7 @@ def create_temp_config():
     default_dirs["STORAGE_TYPE"] = "JSON"
     default_dirs["STORAGE_DETAILS"] = {}
 
-    with config_file.open("r", encoding="utf-8") as fs:
-        config = json.load(fs)
+    config = load_existing_config()
 
     config[name] = default_dirs
 
diff --git a/redbot/launcher.py b/redbot/launcher.py
--- a/redbot/launcher.py
+++ b/redbot/launcher.py
@@ -16,13 +16,13 @@
 from redbot import MIN_PYTHON_VERSION
 from redbot.setup import (
     basic_setup,
-    load_existing_config,
     remove_instance,
     remove_instance_interaction,
     create_backup,
 )
 from redbot.core import __version__, version_info as red_version_info, VersionInfo
 from redbot.core.cli import confirm
+from redbot.core.data_manager import load_existing_config
 
 if sys.platform == "linux":
     import distro  # pylint: disable=import-error
diff --git a/redbot/setup.py b/redbot/setup.py
--- a/redbot/setup.py
+++ b/redbot/setup.py
@@ -37,16 +37,7 @@
     sys.exit(1)
 config_file = config_dir / "config.json"
 
-
-def load_existing_config():
-    if not config_file.exists():
-        return {}
-
-    with config_file.open(encoding="utf-8") as fs:
-        return json.load(fs)
-
-
-instance_data = load_existing_config()
+instance_data = data_manager.load_existing_config()
 if instance_data is None:
     instance_list = []
 else:
@@ -54,7 +45,7 @@ def load_existing_config():
 
 
 def save_config(name, data, remove=False):
-    _config = load_existing_config()
+    _config = data_manager.load_existing_config()
     if remove and name in _config:
         _config.pop(name)
     else:


Test patch: