Okay now I'm getting this error when trying to use...
# plugins
r
Okay now I'm getting this error when trying to use an
await Effect
inside my
goal_rule
Copy code
native_engine.IntrinsicError: Side-effects are not allowed in this context: SideEffecting types must be acquired via parameters to `@rule`s.
1
Code snippet below:
Copy code
await Effect(
            InteractiveProcessResult,
            InteractiveProcess,
            InteractiveProcess.from_process(Process(
                argv=[git_binary.path, "push"],
                description="Push the CI state updates to Github",
                input_digest=registry_digest,
                env={"HOME": os.path.expanduser("~")}
            )),
        )
c
not sure, but you may need to provide the environment as well..? something like:
Copy code
@goal_rule
async def my_goal(..., local_environment: ChosenLocalEnvironmentName) -> ..:
        ...
        process = InteractiveProcess(...)
        res = await Effect(
            InteractiveProcessResult,
            {process: InteractiveProcess, local_environment.val: EnvironmentName},
        )
        ...
although the error message feels like it has nothing to do with ^^
r
Yeah my other plugin's
goal_rule
still works using the normal syntax and both have
environment_behavior = Goal.EnvironmentBehavior.LOCAL_ONLY
in the
Goal
class
c
the error seems to think your
await Effect
is not in a `goal_rule`… 🤷
r
That's what I thought it meant but the error message itself is a bit cryptic too...
Copy code
SideEffecting types must be acquired via parameters to `@rule`s.
That makes it sound like I need to call an
await Get
to even get the side-effecting object
c
ah, no, the “parameters to `@rule`s” part means the args you have on your regular rule:
Copy code
@rule
async def my_rule(param1: ParamType1, param2: ParamType2) -> ...
.. just trying to wrap my head around what that would actually mean in terms of side effecting types..
strange that the same thing works in your other goal. I would probable try to strip down the goal rule to the bare minimum that fails, to see exactly which part is causing this.
r
the whole thing runs right up to the
await Effect
Here's where the error is coming from the engine, though I don't know enough Rust to actually figure out what this is doing 😢 https://github.com/pantsbuild/pants/blob/9382fe26666915be5b9a7cc9d04f222e3a1be2ec/src/rust/engine/src/nodes.rs#L54-L64
c
oh, no I remember a gotcha, you need to depend on a sideeffecting type in your goal rule
i.e. add
Console
or
Workspace
or something to your goal rule params.
without it, pants thinks your goal rule won’t be side effecting at all.
a bit weird.
any type that extends
SideEffecting
.
r
dude you're the 🐐
😁 1
literally saving my life these past few days haha
c
lol- happy to help 😄