#Environment variable propagation

1 messages · Page 1 of 1 (latest)

minor shoal
#

The first thing I do on my base container is use WithEnvVariable to set MAKEFLAGS. I’m expecting that will cause that environment variable to be set in every subsequent call to WithExec.

Is that expectation correct?

dim vector
#

Yes, that's right.

minor shoal
#

Cool! Experimentally, it didn’t look like it was getting set, so I’ll try to debug. Maybe there is some caching in the way.

minor shoal
#

OK, I added some debugging and I'm calling (*Container) EnvVariable(..., "MAKEFLAGS") before each exec make, and it's never set.

dim vector
#

You mean WithEnvVariable? Can you show a simple example?

minor shoal
#

IIUC EnvVariable fetches an environment variable from the container.

#

I can't share code, but I'm doing this:

builder := base.WithEnvVariable("MAKEFLAGS", "-j8").
        With(func(...) { return buildThingA(...) }.
        With(func(...) { return buildThingB(...) }

And in the nested container funcs, I don't see a value for MAKEFLAGS

dim vector
#

Sorry, need to see more. You don't need to share, just if you can make a small example where I can run and confirm the same result.

minor shoal
#

no worries; if I have tiime I'll try to make an example

minor shoal
#

It was a bug in my code. I was had a With() that was capturing the container from the outer function rather than using the parameter.