diff --git a/dedal/utils/utils.py b/dedal/utils/utils.py
index 2f7c48479fb3c0825b06f80e3cc2c70046e4affc..f7fe6620ae29a175e1825e5cb3c0820043a9b554 100644
--- a/dedal/utils/utils.py
+++ b/dedal/utils/utils.py
@@ -97,6 +97,7 @@ def copy_to_tmp(file_path: Path) -> Path:
 def set_bashrc_variable(var_name: str, value: str, bashrc_path: str = os.path.expanduser("~/.bashrc"),
                         logger: logging = logging.getLogger(__name__)):
     """Update or add an environment variable in ~/.bashrc."""
+    value = value.replace("$", r"\$")
     with open(bashrc_path, "r") as file:
         lines = file.readlines()
     pattern = re.compile(rf'^\s*export\s+{var_name}=.*$')