Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError when trying to access env['PIOHOME_DIR'] #2971

Closed
1 of 5 tasks
Pharap opened this issue Sep 2, 2019 · 4 comments
Closed
1 of 5 tasks

KeyError when trying to access env['PIOHOME_DIR'] #2971

Pharap opened this issue Sep 2, 2019 · 4 comments

Comments

@Pharap
Copy link

Pharap commented Sep 2, 2019

What kind of issue is this?

  • Question.
    This issue tracker is not the place for questions. If you want to ask how to do something,
    or to understand why something isn't working the way you expect it to,
    use Community Forums or Premium Support

  • PlatformIO IDE.
    All issues related to PlatformIO IDE should be reported to appropriate repository:
    PlatformIO IDE for Atom or
    PlatformIO IDE for VSCode

  • Development Platform or Board.
    All issues (building, uploading, adding new boards, etc.) related to PlatformIO development platforms
    should be reported to appropriate repository related to your hardware
    https://github.com/topics/platformio-platform

  • Feature Request.
    Start by telling us what problem you’re trying to solve. Often a solution
    already exists! Don’t send pull requests to implement new features without first getting our
    support. Sometimes we leave features out on purpose to keep the project small.

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

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Windows 8.1

PlatformIO Version (platformio --version): PlatformIO 4.0.3

Description of problem

Environment key 'PIOHOME_DIR' does not exist when running a 'pre' script.

Steps to Reproduce

  1. Add the following to platformio.ini:
extra_scripts =
 pre:test.py
  1. Create test.py with the following contents:
Import("env")

print env['PIOHOME_DIR']

Actual Results

Console gives errors:

KeyError: 'PIOHOME_DIR':
  File "C:\users\user\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 124:
    env.SConscript(item, exports="env")
  File "I:\User\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 541:
    return _SConscript(self.fs, *files, **subst_kw)
  File "I:\User\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 250:
    exec _file_ in call_stack[-1].globals
  File "I:\Documents\Github\project\test.py", line 3:
    print env['PIOHOME_DIR']
  File "I:\User\.platformio\packages\tool-scons\script\..\engine\SCons\Environment.py", line 410:
    return self._dict[key]

Expected Results

Console should output either:

C:\users\user\.platformio

Or:

I:\User\.platformio

* C:\users\user\.platformio is a symlink to I:\User\.platformio

@ivankravets
Copy link
Member

pio run -t envdump

See valid variables

@ivankravets
Copy link
Member

You need

PROJECTCORE_DIR=project_helpers.get_project_core_dir(),

@Pharap
Copy link
Author

Pharap commented Sep 2, 2019

Do you happen to know when this change was made?
I couldn't find any mention of the environment variable names changing in the changelog.

Pharap added a commit to Pharap/PokittoIO that referenced this issue Sep 2, 2019
The environment variable name was changed at some point during PlatformIO's development.
See platformio/platformio-core#2971 for more info.
@ivankravets
Copy link
Member

These are internal variables and we use them for own needs. I recommend using PIO Core API instead.

platformio.project.helpers import get_project_core_dir

print(get_project_core_dir())

Please note that Core folder can differ between projects.

Pharap added a commit to Pharap/PokittoIO that referenced this issue Sep 2, 2019
Apparently the old way was using an internal feature rather than the intented public API.
See platformio/platformio-core#2971 for more info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants