Skip to content

--project-dir flag does not work correctly for check and debug commands #5029

Closed
@brawner

Description

@brawner

What kind of issue is this?

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

Configuration

Operating system:
Ubuntu 20.04

PlatformIO Version (platformio --version):
PlatformIO Core, version 6.1.16

Description of problem

I generally work out of the root of my repo, but my platformio projects are nested a couple of levels. So I often run platformio like:

platformio run -d boards/my_project -e deployment

which works great for the run command. But I've noticed it fails on check and debug commands. Whereas moving to that directory and calling check/debug without the -d parameter works fine

Steps to Reproduce

$ platformio check -d boards/my_project -e deployment
$ platformio debug -d boards/my_project -e debug --interface=gdb -x .pioinit

Actual Results

$ platformio check -d boards/my_project -e deployment
Checking deployment > clangtidy (platform: [email protected]; board: esp-wrover-kit; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------
FileNotFoundError: Traceback (most recent call last):
  File "/home/brawner/.local/lib/python3.8/site-packages/platformio/__main__.py", line 103, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/brawner/.local/lib/python3.8/site-packages/platformio/cli.py", line 85, in invoke
    return super().invoke(ctx)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/brawner/.local/lib/python3.8/site-packages/platformio/check/cli.py", line 152, in cli
    ct = CheckToolFactory.new(
  File "/home/brawner/.local/lib/python3.8/site-packages/platformio/check/tools/__init__.py", line 33, in new
    return cls(project_dir, config, envname, options)
  File "/home/brawner/.local/lib/python3.8/site-packages/platformio/check/tools/base.py", line 44, in __init__
    self._load_cpp_data()
  File "/home/brawner/.local/lib/python3.8/site-packages/platformio/check/tools/base.py", line 60, in _load_cpp_data
    data = load_build_metadata(self.project_dir, self.envname)
  File "/home/brawner/.local/lib/python3.8/site-packages/platformio/project/helpers.py", line 140, in load_build_metadata
    with fs.cd(project_dir):
  File "/home/brawner/.local/lib/python3.8/site-packages/platformio/fs.py", line 37, in __enter__
    os.chdir(self.new_path)
FileNotFoundError: [Errno 2] No such file or directory: 'boards/my_project'

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `python -m pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq/index.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions