platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:
https://platformio.org
Apache License 2.0
7.9k stars 792 forks source link

$PROJECT_HASH in build_dir causes exception #4754

Closed bigwave closed 10 months ago

bigwave commented 1 year ago

Configuration

Operating system: Windows 11

PlatformIO Version : PlatformIO Core, version 6.1.11

Description of problem

Using $PROJECT_HASH in build_dir causes exception

Steps to Reproduce

  1. Add build_dir = ${sysenv.TEMP}/pio-workspaces/$PROJECT_HASH/build to platformio.ini
  2. Save platformio.ini

Actual Results

Resolving cubecell_gps dependencies...
Already up-to-date.
Updating metadata for the vscode IDE...
NameError: Traceback (most recent call last):
  File "C:\Users\ian\.platformio\penv\lib\site-packages\platformio\__main__.py", line 103, in main
    cli()  # pylint: disable=no-value-for-parameter
  File "C:\Users\ian\.platformio\penv\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\platformio\cli.py", line 85, in invoke
    return super().invoke(ctx)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\ian\.platformio\penv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\ian\.platformio\penv\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\platformio\project\commands\init.py", line 121, in project_init_cmd
    generator.generate()
  File "C:\Users\ian\.platformio\penv\lib\site-packages\platformio\project\integration\generator.py", line 163, in generate
    contents = self._render_tpl(tpl_path, tpl_vars)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\platformio\project\integration\generator.py", line 169, in _render_tpl
    return bottle.template(fp.read(), **tpl_vars)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\bottle.py", line 3668, in template
    return TEMPLATES[tplid].render(kwargs)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\bottle.py", line 3457, in render
    self.execute(stdout, env)
  File "C:\Users\ian\.platformio\penv\lib\site-packages\bottle.py", line 3444, in execute
    eval(self.co, env)
  File "<string>", line 75, in <module>
NameError: name 'includes' is not defined

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

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

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

`

Expected Results

No exception thrown

If problems with PlatformIO Build System:

The content of platformio.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
build_dir = ${sysenv.TEMP}/pio-workspaces/$PROJECT_HASH/build

[env:cubecell_gps]
platform = heltec-cubecell
board = cubecell_gps
framework = arduino
monitor_speed = 115200
monitor_raw = true
upload_speed = 115200
board_build.arduino.lorawan.region = EU868
board_build.arduino.lorawan.debug_level = FREQ_AND_DIO
board_build.arduino.lorawan.netmode = OTAA
board_build.arduino.lorawan.class = CLASS_A 
board_build.arduino.lorawan.at_support = OFF
board_build.arduino.lorawan.adr = ON
board_build.arduino.lorawan.uplinkmode = UNCONFIRMED
board_build.arduino.lorawan.net_reserve = OFF
board_build.arduino.lorawan.rgb = ACTIVE
board_build.arduino.lorawan.deveui = OFF
extra_scripts = 
    pre:version_increment_pre.py
    post:version_increment_post.py
lib_deps = adafruit/Adafruit AHTX0@^2.0.5

Additional info

ivankravets commented 1 year ago

Does workspace_dir instead of build_dir work for you?

bigwave commented 1 year ago

Still the same error, I'm afraid, with workspace_dir = ${sysenv.TEMP}/pio-workspaces/$PROJECT_HASH/build

ivankravets commented 1 year ago

Hm... I use a similar configuration every day. Instead of patching every platformio.ini, I set a system environment variable PLATFORMIO_WORKSPACE_DIR to /tmp/pio-workspaces/$PROJECT_HASH.

bigwave commented 1 year ago

Set the user environment variable

C:\Users\ian>echo %PLATFORMIO_WORKSPACE_DIR%
C:\WINDOWS\TEMP/pio-workspaces/$PROJECT_HASH/build

But still get exactly the same error at the same location.

ivankravets commented 10 months ago

Duplicate of https://github.com/platformio/platformio-core/issues/4695

ivankravets commented 10 months ago

Thanks for the report. Please re-test with pio upgrade --dev.