diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c75c3094ab440a4b249185721a35c621b7cf0ad8..59ec4499dc5e23da91f12fd6a09edb1eec14c932 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -269,17 +269,18 @@ sync-gitlab-spack-instance:
     - spack load $EBRAINS_SPACK_COMPILER
     - spack compiler find
     - spack compiler list
-    # activate environment (and create it, if it doesn't exist)
+    # create environment, if it doesn't exist
     - spack env list | grep -q $SPACK_NFS_ENV && echo "Environment created already" || spack env create $SPACK_NFS_ENV
-    - spack env activate $SPACK_NFS_ENV
     # update environment site-configs
-    - rm -rf $SPACK_ENV/site-config && cp -r site-config $SPACK_ENV
+    - rm -rf $SPACK_ROOT/var/spack/environments/$SPACK_NFS_ENV/site-config && cp -r site-config $SPACK_ROOT/var/spack/environments/$SPACK_NFS_ENV
     # update spack.yaml: merge top-level and site-specific spack.yaml files
     - spack-python site-config/ymerge.py spack.yaml site-config/$SYSTEMNAME/spack.yaml > /tmp/spack.yaml
-    - cp /tmp/spack.yaml $SPACK_ENV/
+    - cp /tmp/spack.yaml $SPACK_ROOT/var/spack/environments/$SPACK_NFS_ENV
     # There is a known spack bug (https://github.com/spack/spack/issues/29447) in installing test dependencies for installation tests. The workaround suggested
     # in the issue is to NOT concretize separately, but simply remove the .lock file and let the enironment be concretized by the spack install command:
     - rm $SPACK_ROOT/var/spack/environments/$SPACK_NFS_ENV/spack.lock || echo "No spack.lock file"
+    # then activate environment
+    - spack env activate $SPACK_NFS_ENV
     - spack install -y -j2 --fresh --test root
     - spack reindex
   after_script:
diff --git a/install_spack_env.sh b/install_spack_env.sh
index 16311c4712d228d9a0dfc79e9f0c5ae9a934e12c..f4ba7847e58de8655f006259f107097d0a1a5b5a 100644
--- a/install_spack_env.sh
+++ b/install_spack_env.sh
@@ -55,18 +55,19 @@ then
   spack env create $EBRAINS_SPACK_ENV
 fi
 
-# activate environment
-spack env activate $EBRAINS_SPACK_ENV
 # update environment site-configs
-rm -rf $SPACK_ENV/site-config && cp -r $EBRAINS_REPO/site-config $SPACK_ENV
+rm -rf $SPACK_ROOT/var/spack/environments/$EBRAINS_SPACK_ENV/site-config && cp -r $EBRAINS_REPO/site-config $SPACK_ROOT/var/spack/environments/$EBRAINS_SPACK_ENV
 # update spack.yaml: merge top-level and site-specific spack.yaml files
 spack-python $EBRAINS_REPO/site-config/ymerge.py $EBRAINS_REPO/spack.yaml $EBRAINS_REPO/site-config/$SYSTEMNAME/spack.yaml > /tmp/spack.yaml
-cp /tmp/spack.yaml $SPACK_ENV/
+cp /tmp/spack.yaml $SPACK_ROOT/var/spack/environments/$EBRAINS_SPACK_ENV/
 
 # There is a known spack bug (https://github.com/spack/spack/issues/29447) in installing test dependencies
 # for installation tests. The workaround suggested in the issue is to NOT concretize separately, but simply
 # remove the .lock file and let the environment be concretized by the spack install command:
 rm $SPACK_ROOT/var/spack/environments/$EBRAINS_SPACK_ENV/spack.lock || echo "No spack.lock file"
+
+# activate environment
+spack env activate $EBRAINS_SPACK_ENV
 # install the environment, use 2 jobs to reduce the amount of required RAM
 spack install -y -j2 --fresh --test root