tilt icon indicating copy to clipboard operation
tilt copied to clipboard

configuration of subincluded Tiltfiles

Open nicks opened this issue 5 years ago • 3 comments

A question we've gotten a few times in the Tilt channel:

is there any way to access config vars (loaded from tilt_config.json) in a Tiltfile loaded with include?

The problem is that if you try to call config.parse() in more than one Tiltfile, you get

config.parse can only be called from one Tiltfile working directory per run. It was called from /home/nick/src/tilt.build and /home/nick/src/tilt.build/src

Poking at this, I'm not totally sure why this error exists or how configs are supposed to work in the presence of multiple Tiltfiles.

@landism do you remember the history behind this?

nicks avatar Sep 18 '20 14:09 nicks

I'm not totally sure why this error exists or how configs are supposed to work in the presence of multiple Tiltfiles.

The current way it's supposed to work in the presence of multiple Tiltfiles is: only the root Tiltfile can define or access config vars.

This error was added to allow us to get a useable version out and get actual users and see what they valued.

Most of the effort on this feature (unfortunately?) went into negotiating the persistence story (originally the plan was that args passed on command line would be saved to tilt_config.json and be persistent), and that interaction with multiple Tiltfiles seemed like a reasonable thing to rope off to get something out the door.

Some complications that come into play with multiple Tiltfiles:

  • Does config.parse load params defined anywhere, or only in the current Tiltfile? I could see users having either expectation and being surprised / confused / annoyed at the other.
  • Does config.parse load tilt_config.json from next to the current Tiltfile or the root Tiltfile? There are use cases for both, though at this point we've been downplaying composable Tiltfiles for a while now.
  • Do we still error on unrecognized args? I think there's a lot of value in this, but it gets messy if we have multiple arg sets.

I don't think any of these are blockers, just...cost increasers.

landism avatar Sep 30 '20 19:09 landism

ya, it feels like this is a consequence of a syntax that looks like argparse (which you really can't distribute across multiple files, afaik)

but people want to use it more like Go's flag parser or like Bazel's config_setting https://docs.bazel.build/versions/3.5.0/be/general.html#config_setting

nicks avatar Sep 30 '20 19:09 nicks

FWIW, I just ran into this issue and, as a workaround, decided to use environment variables to configure the various Tiltfiles instead of using the config.

emschwartz avatar Jan 31 '22 19:01 emschwartz