summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/fm.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index d29e446b..e9ffb888 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -167,12 +167,22 @@ class FM(Actions, SignalDispatcher):
             sys.stderr.write("refusing to copy config files in clean mode\n")
             return
         import shutil
+        from errno import EEXIST
         def copy(_from, to):
             if os.path.exists(self.confpath(to)):
                 sys.stderr.write("already exists: %s\n" % self.confpath(to))
             else:
                 sys.stderr.write("creating: %s\n" % self.confpath(to))
                 try:
+                    os.makedirs(ranger.arg.confdir)
+                except OSError as err:
+                    if err.errno != EEXIST:  # EEXIST means it already exists
+                        print("This configuration directory could not be created:")
+                        print(ranger.arg.confdir)
+                        print("To run ranger without the need for configuration")
+                        print("files, use the --clean option.")
+                        raise SystemExit()
+                try:
                     shutil.copy(self.relpath(_from), self.confpath(to))
                 except Exception as e:
                     sys.stderr.write("  ERROR: %s\n" % str(e))