Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions containers/eic/profile.d/z99_spack_lazy_load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Create function for first invocation of spack
# that loads environment to avoid slow loads
# when sourcing environment by default
Comment on lines +3 to +5

Copilot AI Apr 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment describes the intent, but it doesn’t mention the key behavioral detail that the wrapper unsets itself after the first call. Please update the comment to document the one-time behavior (and any assumptions like SPACK_ROOT being set), since this affects debugging and future maintenance.

Suggested change
# Create function for first invocation of spack
# that loads environment to avoid slow loads
# when sourcing environment by default
# Create a one-time wrapper for the first invocation of `spack`.
# On first use, this function unsets itself, sources Spack's setup script,
# and then re-runs `spack` so subsequent invocations use the real Spack
# function/command from setup-env.sh without paying the shell startup cost
# of sourcing the environment by default. Assumes `SPACK_ROOT` is already
# set to the root of a valid Spack installation.

Copilot uses AI. Check for mistakes.
spack() {
unset -f spack
source "${SPACK_ROOT}/share/spack/setup-env.sh"
Comment thread
veprbl marked this conversation as resolved.
Comment thread
veprbl marked this conversation as resolved.
Comment thread
veprbl marked this conversation as resolved.
spack "$@"
}
Loading