<commit_before>diff --git a/modules/cctbx_project/libtbx/env_config.py b/modules/cctbx_project/libtbx/env_config.py
index d1691bbeb2..3428f24045 100644
--- a/modules/cctbx_project/libtbx/env_config.py
+++ b/modules/cctbx_project/libtbx/env_config.py
@@ -1174,10 +1174,10 @@ Wait for the command to finish, then try again.""" % vars())
     with target_file.open('w') as f:
       if sys.platform == 'win32':  # windows
         print('@setlocal', file=f)
-        # print('@set LIBTBX_BUILD=%~dp0', file=f)
-        # print('@set LIBTBX_BUILD=%LIBTBX_BUILD:~0,-1%', file=f)
-        # print(r'@for %%F in ("%LIBTBX_BUILD%") do @set LIBTBX_BUILD=%%~dpF', file=f)
-        # print('@set LIBTBX_BUILD=%LIBTBX_BUILD:~0,-1%', file=f)
+        print('@set LIBTBX_PREFIX=%~dp0', file=f)
+        print('@set LIBTBX_PREFIX=%LIBTBX_PREFIX:~0,-1%', file=f)
+        print(r'@for %%F in ("%LIBTBX_PREFIX%") do @set LIBTBX_PREFIX=%%~dpF', file=f)
+        print('@set LIBTBX_PREFIX=%LIBTBX_PREFIX:~0,-1%', file=f)
         print('@set LIBTBX_DISPATCHER_NAME=%~nx0', file=f)
         def write_dispatcher_include(where):
           for line in self.dispatcher_include(where=where):
@@ -1186,18 +1186,18 @@ Wait for the command to finish, then try again.""" % vars())
             else :
               print("@" + line, file=f)
         write_dispatcher_include(where="at_start")
-        print('@set LIBTBX_PYEXE=%s' % self.python_exe.bat_value(), file=f)
+        print('@set LIBTBX_PYEXE=%s' % self.python_exe.bat_value(anchor_var='LIBTBX_PREFIX'), file=f)
         write_dispatcher_include(where="before_command")
         qnew_tmp = qnew
         if self.python_version_major_minor[0] == 3:
           qnew_tmp = '' # -Q is gone in Python3.
         if source_file.ext().lower() == '.py':
           print('@"%%LIBTBX_PYEXE%%"%s "%s" %%*' % (
-            qnew_tmp, source_file.bat_value()), file=f)
+            qnew_tmp, source_file.bat_value(anchor_var='LIBTBX_PREFIX')), file=f)
         elif source_file.basename().lower() == 'python.exe':
           print('@"%%LIBTBX_PYEXE%%"%s %%*' % qnew_tmp, file=f)
         else:
-          print('@"%s" %%*' % source_file.bat_value(), file=f)
+          print('@"%s" %%*' % source_file.bat_value(anchor_var='LIBTBX_PREFIX'), file=f)
       else:  # linux and macOS
         if (source_file is not None):
           print('#! /bin/sh', file=f)
@@ -1627,7 +1627,7 @@ Wait for the command to finish, then try again.""" % vars())
           + "    %s\n" % show_string(abs(source_file))
           + "   =%s" % source_file)
     if abs(self.build_path) == get_conda_prefix() or \
-      (os.name == "nt" and abs(self.build_path).endswith('Library')):
+      (os.name == "nt" and abs(self.build_path).lower().endswith('library')):
       action = self.write_conda_dispatcher
     elif (os.name == "nt"):
       action = self.write_win32_dispatcher
@@ -3044,6 +3044,15 @@ def unpickle(build_path=None, env_name="libtbx_env"):
     env.installed_modules = []
   if not hasattr(env, "installed_order"):
     env.installed_order = []
+  # update installed location
+  if env.installed:
+    sys_prefix = get_conda_prefix()
+    if sys.platform == 'win32':
+      sys_prefix = op.join(sys_prefix, 'library')
+    sys_prefix = absolute_path(sys_prefix)
+    for i in range(len(env.repository_paths)):
+      env.repository_paths[i]._anchor = sys_prefix
+    env.set_derived_paths()
   return env

 def warm_start(args):
<commit_msg>Update fewer paths<commit_after>diff --git a/modules/cctbx_project/libtbx/env_config.py b/modules/cctbx_project/libtbx/env_config.py
index d1691bbeb2..3428f24045 100644
--- a/modules/cctbx_project/libtbx/env_config.py
+++ b/modules/cctbx_project/libtbx/env_config.py
@@ -1174,10 +1174,10 @@ Wait for the command to finish, then try again.""" % vars())
     with target_file.open('w') as f:
       if sys.platform == 'win32':  # windows
         print('@setlocal', file=f)
-        # print('@set LIBTBX_BUILD=%~dp0', file=f)
-        # print('@set LIBTBX_BUILD=%LIBTBX_BUILD:~0,-1%', file=f)
-        # print(r'@for %%F in ("%LIBTBX_BUILD%") do @set LIBTBX_BUILD=%%~dpF', file=f)
-        # print('@set LIBTBX_BUILD=%LIBTBX_BUILD:~0,-1%', file=f)
+        print('@set LIBTBX_PREFIX=%~dp0', file=f)
+        print('@set LIBTBX_PREFIX=%LIBTBX_PREFIX:~0,-1%', file=f)
+        print(r'@for %%F in ("%LIBTBX_PREFIX%") do @set LIBTBX_PREFIX=%%~dpF', file=f)
+        print('@set LIBTBX_PREFIX=%LIBTBX_PREFIX:~0,-1%', file=f)
         print('@set LIBTBX_DISPATCHER_NAME=%~nx0', file=f)
         def write_dispatcher_include(where):
           for line in self.dispatcher_include(where=where):
@@ -1186,18 +1186,18 @@ Wait for the command to finish, then try again.""" % vars())
             else :
               print("@" + line, file=f)
         write_dispatcher_include(where="at_start")
-        print('@set LIBTBX_PYEXE=%s' % self.python_exe.bat_value(), file=f)
+        print('@set LIBTBX_PYEXE=%s' % self.python_exe.bat_value(anchor_var='LIBTBX_PREFIX'), file=f)
         write_dispatcher_include(where="before_command")
         qnew_tmp = qnew
         if self.python_version_major_minor[0] == 3:
           qnew_tmp = '' # -Q is gone in Python3.
         if source_file.ext().lower() == '.py':
           print('@"%%LIBTBX_PYEXE%%"%s "%s" %%*' % (
-            qnew_tmp, source_file.bat_value()), file=f)
+            qnew_tmp, source_file.bat_value(anchor_var='LIBTBX_PREFIX')), file=f)
         elif source_file.basename().lower() == 'python.exe':
           print('@"%%LIBTBX_PYEXE%%"%s %%*' % qnew_tmp, file=f)
         else:
-          print('@"%s" %%*' % source_file.bat_value(), file=f)
+          print('@"%s" %%*' % source_file.bat_value(anchor_var='LIBTBX_PREFIX'), file=f)
       else:  # linux and macOS
         if (source_file is not None):
           print('#! /bin/sh', file=f)
@@ -1627,7 +1627,7 @@ Wait for the command to finish, then try again.""" % vars())
           + "    %s\n" % show_string(abs(source_file))
           + "   =%s" % source_file)
     if abs(self.build_path) == get_conda_prefix() or \
-      (os.name == "nt" and abs(self.build_path).endswith('Library')):
+      (os.name == "nt" and abs(self.build_path).lower().endswith('library')):
       action = self.write_conda_dispatcher
     elif (os.name == "nt"):
       action = self.write_win32_dispatcher
@@ -3044,6 +3044,16 @@ def unpickle(build_path=None, env_name="libtbx_env"):
     env.installed_modules = []
   if not hasattr(env, "installed_order"):
     env.installed_order = []
+  # update installed location
+  if env.installed:
+    sys_prefix = get_conda_prefix()
+    if sys.platform == 'win32':
+      sys_prefix = op.join(sys_prefix, 'library')
+    sys_prefix = absolute_path(sys_prefix)
+    for i in range(len(env.repository_paths)):
+      env.repository_paths[i]._anchor = sys_prefix
+    env.bin_path._anchor = sys_prefix
+    env.exe_path._anchor = sys_prefix
   return env

 def warm_start(args):

{'fraction_non_alphanumeric': 0.1738880918220947, 'fraction_numerical': 0.024390243902439025, 'mean_word_length': 3.232544019429265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4008691', 'n_tokens_mistral': 2754, 'n_tokens_neox': 2559, 'n_words': 443}