diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py
index aaa2c13f..bb375404 100644
--- a/lib/cdist/exec.py
+++ b/lib/cdist/exec.py
@@ -45,7 +45,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
     except subprocess.CalledProcessError:
         log.error("Code that raised the error:\n")
 
-        run_or_fail(["cat", script], remote_prefix=remote_prefix)
+        if remote_prefix:
+            run_or_fail(["cat", script], remote_prefix=remote_prefix)
 
         else:
             try: