Tilt: Allow `include`d/`load`'d files to use tilt extensions

Created on 12 Jun 2020  路  11Comments  路  Source: tilt-dev/tilt

It's very helpful to be able to organize your tiltfile by separating sections out into smaller files that can be included into the main Tiltfile. However, those sub-files are unable to make use of tilt extensions. There are 2 ways we can fail at this:

Attempt, the first

Main Tiltfile

include('otherfile.tilt')  # this is just more tiltfile, NOT an extension, and NOT defining shared functions

Other Tiltfile

load('ext://someExtension', 'someFunction')
someFunction('doAThing')

This fails with: Error: cannot load ext://git_resource: extensions cannot be loaded from `load`ed Tiltfiles which is confusing, since this file was included, not loaded.

Ok, so let's load the extension first, and _then_ include our sub-file...

Attempt, the second

Main Tiltfile

load('ext://someExtension', 'someFunction')  # load this first, so our included file can make use of it
include('otherfile.tilt')  # this is just more tiltfile, NOT an extension, and NOT defining shared functions

Other Tiltfile

someFunction('doAThing')

This one fails with: Error: /path/to/otherfile.tilt:1:1: undefined: someFunction which suggests the included file doesn't share global context with the main tiltfile.

*If included files aren't capable of using extensions, it creates a _major_ limitation to organizing our scripts in this fashion.

enhancement extensions

Most helpful comment

This should be fixed in the latest release -- let us know if you run into any trouble!

All 11 comments

@victorwuky is this relatively simple enough that it might land soon, or is it more likely a ways down the line?

@victorwuky for what it's worth, while it would definitely be nice for extensions to also load files, it seems to me like that's less important than the ability for non-extension, local includes to be able to make use of existing extensions.

Thanks @KOGI for the comment. Right now we don't have a clear timeline of when we'd pick up this feature in particular.

@KOGI to give a little more context, it turns out this feature isn't actually that simple because (among other things) we'd need to do a lot of work around handling working directories and all the inevitable edge cases. So--we'll keep you posted!

@maiamcc can you elaborate a bit more on why this is difficult to solve?

Ya, it seems like this should be much higher priority if it blocks the ability to use the restart_process extension

@maiamcc Your comment on https://github.com/tilt-dev/tilt-extensions/issues/37 makes me think you might be confusing two different issues:

1) load()-ing extensions from other extensions raises questions about how we version extensions, and handle diamond dependencies (https://github.com/tilt-dev/tilt/issues/3472)
2) load()-ing extensions from other sub-included files in the "normal" repo doesn't raise any versioning concerns, and is much easier to resolve

# 1 would be nice
# 2 is what this issue is asking for

@maiamcc how do you feel about removing the restart_process deprecation warning until this issue is resolved? seems like this issue is a blocker to adoption of restart_process.

Ugh yeah I was hoping it wouldn't be that hard to fix this issue, but since it's almost 3, I guess I'll revert the deprecation warning for today's release :-/

This should be fixed in the latest release -- let us know if you run into any trouble!

Woo! Works like a charm! Thank you all!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kvokka picture kvokka  路  7Comments

ozburo picture ozburo  路  7Comments

david-martyn-ford picture david-martyn-ford  路  4Comments

mnpenner picture mnpenner  路  4Comments

damoon picture damoon  路  3Comments