Mu2e / Muse

Code build system to be used to build multiple repos together
Apache License 2.0
0 stars 5 forks source link

Suggestion for a new spack era environment variable #109

Open kutschke opened 2 months ago

kutschke commented 2 months ago

On the is_it_me_or_a_bug slack channel Pasha points out:

https://mu2e.slack.com/archives/C72755LAE/p1719187991527409

The online spack environment defines SPACK_VIEW, which points at, for example:

/cvmfs/mu2e.opensciencegrid.org/packages/spack/v0.21.0-dev.fermi/NULL/var/spack/environments/mu2e-3-14-03-al9-e28-prof-3/.spack-env/view

In the offline environment we have SPACK_ENV, which is similar but omits the last two elements of the path.

Do we want to define SPACK_ENV in the offline environment?

pavel1murat commented 2 months ago

it is not the Mu2e online, it is spack itself which defines SPACK_ENV via spack env activate

rlcee commented 2 months ago

What is spack-env.sh and where does SPACK_VIEW get set online?

kutschke commented 2 months ago

What is spack-env.sh and where does SPACK_VIEW get set online?

@pavel1murat do you know the answers? I don't.

pavel1murat commented 2 months ago

, the same as  `ls $SPACK_ROOT/var/spack/environments`
* our today's environment activated by `muse setup` is `mu2e-3-14-03-al9-e28-prof-3`
rlcee commented 2 months ago

I'm sorry to be slow, but I still don't see SPACK_VIEW anywhere, not in scripts or docs, and we don't get it when activating an env. Maybe it is something Eric customized for online? (I created SPACK_LOCAL to point into the padded build area, for example)

build02 spack > spack env activate mu2e-3-14-03-al9-e28-prof-3
build02 spack > printenv SPACK_VIEW
build02 spack > spack env deactivate
build02 spack > spack env activate -v default mu2e-3-14-03-al9-e28-prof-3
build02 spack > printenv SPACK_VIEW

Maybe I am being slow. Was the point here to ask me to go into the script and add it myself? I think I was reading this thread wrong.

pavel1murat commented 2 months ago

try without -v default - that is the piece responsible for SPACK_ENV not being set...

pavel1murat commented 2 months ago

to have $SPACK_ENV showing up, I first had to deactivatemu2e-3-14-03-al9-e28-prof-3

mu2epro@mu2egpvm05:~/murat/pipenu_prof>spack env list
==> 21 environments
    critic-2-13-03-e28-prof-0                        mu-3-14-03-e28-prof-0                        mu2e-3-14-03-al9-e28-prof-3  muse-ext-p052-al9-e28-prof
    critic-2-13-03-gcc-13-1-0-cxx20-prof-gcc-11-4-1  mu-3-14-03-e28-prof-1                        mu2e-3-14-03-sl7-e28-prof-0  muse-ext-p052-gcc-13-1-0-cxx20-prof-gcc-11-4-1
    gcc-13-1-0-gcc-11-4-1                            mu-3-14-03-gcc-13-1-0-cxx20-prof-gcc-11-4-1  mu2e-3-14-03-sl7-e28-prof-1  muse-ext-p052-slf7-e28-prof
    geant4-11-1-2-gcc-13-1-0-cxx20-prof-gcc-11-4-1   mu2e-3-14-03-al9-e28-prof-0                  mu2e_externals_v3
    mu-3-14-03-al9-e28-prof-0                        mu2e-3-14-03-al9-e28-prof-1                  mu2e_externals_v4
    mu-3-14-03-al9-e28-prof-1                        mu2e-3-14-03-al9-e28-prof-2                  muse-ext-p050-slf7-e28-prof
mu2epro@mu2egpvm05:~/murat/pipenu_prof>echo $SPACK_VIEW

mu2epro@mu2egpvm05:~/murat/pipenu_prof>echo $SPACK_ENV

mu2epro@mu2egpvm05:~/murat/pipenu_prof>spack env activate mu2e-3-14-03-al9-e28-prof-3
mu2epro@mu2egpvm05:~/murat/pipenu_prof>echo $SPACK_ENV
/cvmfs/mu2e.opensciencegrid.org/packages/spack/v0.21.0-dev.fermi/NULL/var/spack/environments/mu2e-3-14-03-al9-e28-prof-3
rlcee commented 2 months ago

SPACK_ENV should only be present when you have an active env, which you seem to agree with. But I still don't understand how to do SPACK_VIEW, so I'd like to see how it is done online. Obviously SPACK_VIEW would not be defined until you activate a env with a view. Since an env can have multiple views, the system picks one based on your activate command, so that would have to be tracked. This information does exist deep in the bowels of spack env activate code, which I can modify, but there is some risk to touching that. So I'm wondering if Eric did this mod, or am I missing something? A different approach is to set SPACK_VIEW in the muse envset, Here, muse is acting as a wrapper to "spack env activate" so it has control of the activate and has the opportunity to set this, but of course this is outside of spack.

kutschke commented 2 months ago

My advice is to do this as natively as possible but from time to time it may make sense to use muse as a helper, perhaps only a transient helper.