Repository: spyder-ide/spyder

Issue:
Error when loading configuration file
I can't open Spyder via Anaconda, if i want to start spyder, the loading bar will apear but after that nothing happen. Also if i want to update it to a newer version like 5.0.5, it will load until infinity.

If i want to open spyder via the terminal, this will appear:

(base) C:\Users\fuzhan>spyder
Traceback (most recent call last):
File "C:\Users\fuzhan\anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\Users\fuzhan\anaconda3\lib\site-packages\spyder\app\start.py", line 97, in main
from spyder.config.manager import CONF
File "C:\Users\fuzhan\anaconda3\lib\site-packages\spyder\config\manager.py", line 351, in
CONF = ConfigurationManager()
File "C:\Users\fuzhan\anaconda3\lib\site-packages\spyder\config\manager.py", line 64, in init
self._user_config = MultiUserConfig(
File "C:\Users\fuzhan\anaconda3\lib\site-packages\spyder\config\user.py", line 782, in init
self._configs_map[name] = config_class(**new_kwargs)
File "C:\Users\fuzhan\anaconda3\lib\site-packages\spyder\config\user.py", line 212, in init
self._load_from_ini(previous_fpath)
File "C:\Users\fuzhan\anaconda3\lib\site-packages\spyder\config\user.py", line 333, in _load_from_ini
self.read(fpath, encoding='utf-8')
File "C:\Users\fuzhan\anaconda3\lib\configparser.py", line 697, in read
self._read(fp, filename)
File "C:\Users\fuzhan\anaconda3\lib\configparser.py", line 1067, in _read
raise DuplicateSectionError(sectname, fpname,
configparser.DuplicateSectionError: While reading from 'C:\Users\fuzhan\.spyder-py3\config\transient.ini' [line 117]: section 'find_in_files' already exists

I have already deleted spyder, as well as anaconda and installed it new, but nothing changed.

Ps. i hope i posted this issue in the right category, i am new in GitHub.


Discussion:
Hey @Programmfailer, thanks for reporting. Please run the following command in the Anaconda Prompt:

    spyder --reset

and after that, start Spyder again. That should solve your problem.

Let us know if it works for you. 
Note: we should catch and load our default config with this kind of errors because there's nothing else users can do about them than resetting their preferences.
thanks for your help, the reset worked.
Great! I'm reopening this because we plan to do this automatically in one of our next versions. 
@dalthviz, this is a serious bug because any error when loading/reading our config files generates a crash at startup. My idea to solve this is catching those errors and load our default config values instead.
So in case of errors loading/reading the config should get resetted (probably showing a dialog saying to the user that in order to continue the config should be resetted)? Or just the load?

Probably If you load the default values but you don't reset the config then the config causing the error will not be removed and probably when trying to write to the config files more errors could arise, right?
> Probably If you load the default values but you don't reset the config then the config causing the error will not be removed and probably when trying to write to the config files more errors could arise, right?

Yeah, that's a very good point. In Spyder 3 we were simply loading the default config instead of resetting it. But, as you said, that will never fix the underlying error.

So I agree with you and now I think we need the reset the user's config and inform them with a dialog that we needed to do that because their previous configuration was broken.

Resolving patch:
diff --git a/spyder/config/manager.py b/spyder/config/manager.py
--- a/spyder/config/manager.py
+++ b/spyder/config/manager.py
@@ -17,7 +17,8 @@
 
 # Local imports
 from spyder.api.utils import PrefixedTuple
-from spyder.config.base import _, get_conf_paths, get_conf_path, get_home_dir
+from spyder.config.base import (
+    _, get_conf_paths, get_conf_path, get_home_dir, reset_config_files)
 from spyder.config.main import CONF_VERSION, DEFAULTS, NAME_MAP
 from spyder.config.types import ConfigurationKey, ConfigurationObserver
 from spyder.config.user import UserConfig, MultiUserConfig, NoDefault, cp
@@ -637,4 +638,21 @@ def reset_shortcuts(self):
             plugin_config.reset_to_defaults(section='shortcuts')
 
 
-CONF = ConfigurationManager()
+try:
+    CONF = ConfigurationManager()
+except Exception:
+    from qtpy.QtWidgets import QMessageBox
+    from spyder.app.utils import create_application
+    app = create_application()
+    reset_reply = QMessageBox.critical(
+        None, 'Spyder',
+        _("There was an error while loading Spyder configuration options. "
+          "You need to reset them for Spyder to be able to launch.\n\n"
+          "Do you want to proceed?"),
+        QMessageBox.Yes, QMessageBox.No)
+    if reset_reply == QMessageBox.Yes:
+        reset_config_files()
+        QMessageBox.information(
+            None, 'Spyder',
+            _("Spyder configuration files resetted!"))
+    os._exit(0)


Test patch: