platformio / platformio/platformio-core

`pio remote run --force-remote` doesn't propagate environment variables to the agent.

Open
#4,697 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9.5k
Forks
905
Avg merge
2d 13h
Merged PRs (30d)
2

Description

  • PlatformIO Core.
    If you’ve found a bug, please provide an information below.
Configuration

Operating system: Ubuntu 22.04

PlatformIO Version (platformio --version): 6.1.9

Description of problem

TLDR; environment variables set aren’t propagated when using pio remote run --force-remote.

I have a project that is configurable using a #define to control whether the firmware waits for a serial connection or not. Handy for development, but not so much for CI, so this feature is switched off in the CI build.

I set `PLATFORMIO_BUILD_FLAGS=“-DNO_WAIT_FOR_SERIAL” in the environment but found that this wasn’t propagated to the agent. Is this expected?

The workaround for me was to simply not use --force-remote.

I looked but didn’t find any documentation for this behavior, which was surprising since environment variables are a key part of project configuration.

Steps to Reproduce
  1. Define an environment variable that makes a measurable change to a PlatformIO project
  2. Build the project with pio remote run -t upload --force-remote
  3. Evaluate the affect of the environment variable.
Actual Results

The environment variable isn't propagated to the runner, and consequently the built firmware doesn't include the functionality activated by the environment variable.

Expected Results

The environment variable is propagated. This may require a whitelist or similar, so that only specific variables are propagated.

Additional info

The behavior is understandable - there could be security issues with propagating variables from the calling environment into the agent. (A whitelist/blacklist may help mitigate this.)

If a working solution isn't possible, a mention of the behavior in the docs for --force-remote would help others be aware of the behavior change.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior with PLATFORMIO_BUILD_FLAGS and pio remote run -t upload --force-remote, then inspect the implementation and documentation for the --force-remote command and its agent communication. Done means the environment-variable behavior is safely defined and implemented, with coverage or documentation for the resulting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.