Leading newline in multiline upload_port breaks device monitor port resolution

Open Beginner friendly
#5,552 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start by tracing how pio project config --json-output parses and resolves upload_port, then follow how pio device monitor -e rx receives monitor_port. Check the existing tests for multiline configuration values and single-value serial port options. Done when the indented value resolves to the same path as the inline value and the monitor can use it without a leading newline.

Written by the indexing model from the issue text.

Description

  • PlatformIO Core
Configuration
  • Operating system: macOS 26.6 (arm64)
  • PlatformIO Core: 6.2.0
Steps to reproduce

Create a platformio.ini with a single serial port specified on an indented continuation line:

[env]
monitor_port = ${this.upload_port}

[env:rx]
platform = espressif32
board = seeed_xiao_esp32s3
framework = arduino
upload_port =
    /dev/cu.usbmodem201301
    ; /dev/cu.usbmodem2011101
  1. Run pio project config --json-output. No hardware is required for this step.
  2. To see the runtime failure, substitute a connected device's serial port and run pio device monitor -e rx directly in an interactive terminal, without a pipe.
Actual results

The resolved upload_port and monitor_port values both contain a leading newline ("\n/dev/cu.usbmodem201301"). The monitor passes that string to pySerial and fails to open the port with No such file or directory, even though the device exists. Stating the same value on the assignment line (upload_port = /dev/cu.usbmodem201301) works.

Expected results

For these single-value serial port options, ignore surrounding whitespace after resolving the INI value and interpolation. The indented form with one port should resolve to the same path as the inline form. This would preserve the behavior of other multiline options.

Additional information

Python's ConfigParser accepts the continuation syntax and preserves the leading newline.

Dominant language
Python
Stars
9.6k
Forks
916
PR merge metrics
No merged PRs in 30d

Getting set up

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.

More from platformio/platformio-core

All issues in platformio/platformio-core

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.