mirror of
https://github.com/amidaware/tacticalrmm.git
synced 2026-04-26 15:05:57 +03:00
[GH-ISSUE #2209] [BUG] Env vars are not refreshed between scripts environements #3315
Labels
No labels
In Process
bug
bug
dev-triage
documentation
duplicate
enhancement
fixed
good first issue
help wanted
integration
invalid
pull-request
question
requires agent update
security
ui tweak
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tacticalrmm#3315
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @P6g9YHK6 on GitHub (Apr 15, 2025).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/2209
Describe the bug
ENV is not refreshed between scripts environments for exemple when working between python and powershell require a restart of the agent.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
env should be refreshed on each script run to avoid missing var set by another script.
@silversword411 commented on GitHub (Apr 18, 2025):
This is expected behavior due to how environment variables are handled at the process level. When you set an environment variable in PowerShell (or any process), it only affects:
The current PowerShell process ($env:MY_VAR)
Optionally, the User or Machine registry (via SetEnvironmentVariable) — but changes there only apply to new processes started after the change.
Python (or any other script runner) will not see the updated variable unless it's started after the environment is refreshed, which typically means restarting the agent or the host process managing these scripts.
Why this happens: Each script runs in its own process context, and environment variables are inherited at process launch — they are not live-synced between processes.
Workaround: If you need to pass values between scripts, consider:
Using files or a shared temp location
Using custom fields (if Tactical RMM)
Restarting the agent or script host after setting persistent env vars
@P6g9YHK6 commented on GitHub (Apr 18, 2025):
i don't think it would be too much to expect that each runtime simply refresh the env vars at each run and should be fairly minimal on resource impact.
using files is not really a good practice for stuff that can fit in ENV.
and not everything should be a custom field when it should be bound to the device and not sensitive to a trmm agent reinstall for exemple.
or i will end up having to make a task to do the workaround of restarting the agent run on each agent on a regular basis and i don't believe this should be the solution to this uniquely "trmm agent" issue.
@silversword411 commented on GitHub (Apr 22, 2025):
Didn't know about
refreshenvmaybe an equivalent can be added, or a service restart on install would work around the problem of the agent being a subprocesses with limited environment on first start after install.