Show the real error message instead of "Can not remove temporary directory" when "platform.ini" is broken // Resolve #4480

This commit is contained in:
Ivan Kravets
2023-01-13 19:56:08 +02:00
parent 5ee79f1724
commit 17360b0ed2
3 changed files with 11 additions and 1 deletions

View File

@ -20,6 +20,7 @@ PlatformIO Core 6
* Made assets (templates, ``99-platformio-udev.rules``) part of Python's module (`issue #4458 <https://github.com/platformio/platformio-core/issues/4458>`_)
* Updated `Clang-Tidy <https://docs.platformio.org/en/latest/plus/check-tools/clang-tidy.html>`__ check tool to v15.0.5 with new diagnostics and bugfixes
* Removed dependency on the "zeroconf" package and install it only when a user lists mDNS devices (issue with zeroconf's LGPL license)
* Show the real error message instead of "Can not remove temporary directory" when "platform.ini" is broken (`issue #4480 <https://github.com/platformio/platformio-core/issues/4480>`_)
6.1.5 (2022-11-01)
~~~~~~~~~~~~~~~~~~

View File

@ -319,7 +319,13 @@ class ProjectConfigBase:
if section == "this":
section = parent_section
if option == "__env__":
assert parent_section.startswith("env:")
if not parent_section.startswith("env:"):
raise exception.ProjectOptionValueError(
f"`${{this.__env__}}` is called from the `{parent_section}` "
"section that is not valid PlatformIO environment, see",
option,
section,
)
return parent_section[4:]
# handle nested calls
try:

View File

@ -24,6 +24,7 @@ from tabulate import tabulate
from platformio import app, exception, fs, util
from platformio.device.monitor.command import device_monitor_cmd
from platformio.project.config import ProjectConfig
from platformio.project.exception import ProjectError
from platformio.project.helpers import find_project_dir_above, load_build_metadata
from platformio.run.helpers import clean_build_dir, handle_legacy_libdeps
from platformio.run.processor import EnvironmentProcessor
@ -115,6 +116,8 @@ def cli(
build_dir = config.get("platformio", "build_dir")
try:
clean_build_dir(build_dir, config)
except ProjectError as exc:
raise exc
except: # pylint: disable=bare-except
click.secho(
"Can not remove temporary directory `%s`. Please remove "