I have rigged the PlatformIO Core, cannot be installed any longer!

Hi all,

I am in a deep mess. It started that our project on google drive can only be compiled on my computer, as it seeminlgy has many local references. But even when I try to replace all local references to my drive with ${env:PLATFORMIO_PACKAGES_DIR} in the c_cpp_properties.json folder I still get errors. The problem is really that I do not know where and how all of these environment variables are stored (in Windows system files accessible through the power shell, cmd or in Jason files that are accessible through Python/PlatformIO?). There are so many layers, it seems that even Python is allowed to create special shell contexts through its environment wizzardry.

So I have asked Chatgpt how to install platform so that it can be used for all users I got something like that, to be executed as an administrator on the power shell:

[System.Environment]::SetEnvironmentVariable(“PLATFORMIO_PACKAGES_DIR”, “G:\Shared_PIO\platformio\packages”, “Machine”)

where G:\Shared_PIO\platformio\packages is replaced by the network drive onto which the workspace is saved, so this supposededly should install everything on the network. A big mistake as I am no longer able to load platformio and I get the following error

*Error: Traceback (most recent call last):*
*  File "<frozen runpy>", line 198, in _run_module_as_main*
*  File "<frozen runpy>", line 88, in _run_code*
*  File "G:\Shared drives\Raw Data Storage\Git\FW-32004-100\penv\Lib\site-packages\pip\__main__.py", line 24, in <module>*
*    sys.exit(_main())*
*             ~~~~~^^*
*  File "G:\Shared drives\Raw Data Storage\Git\FW-32004-100\penv\Lib\site-packages\pip\_internal\cli\main.py", line 78, in main*
*    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))*
*  File "G:\Shared drives\Raw Data Storage\Git\FW-32004-100\penv\Lib\site-packages\pip\_internal\commands\__init__.py", line 114, in create_command*
*    module = importlib.import_...*

I think that that the Python environment looks for its own executable on the network (have removed all env folders) and not on the local drive (to which it is installed). So probably the python interpreter wants to run itself from the network but that is no longer possible.

I have uninstalled vscode and python but to no avail.

I am in desparate desparate need to
a) a nuclear option to reset all this mess, and
b) a way to make use of some relative environment variables (Python or Windows) to replace direct references to local directories so that I am finally able to collaborate with others.

many thanks in advance,
yours in desperation,
C.

https://docs.platformio.org/en/latest/envvars.html lists any environments that PlatformIO respects.

You can set and unset environment variables e.g. per this tutorial.

Never use whitespaces in Path. Platformio and espressif toolchains can’t handle this

Thank you, I know how to set environment variables in Windows, but there seems to be a difference in when, how and where they are being read. For example, in platform.ini the variable ${platformio.packages_dir} is pefectly understood, but the settings for the compiler seem to be handled differently.

Although I specify the ${platformio.packages_dir} within platformio.ini the .json files wihtin .vscode are not updated with ${platformio.packages_dir} but still contain the “C:/Users/xxx/.platformio/packages…” as reference. Are these expanded?

This seems to be a problem when other users are accessing the same workspace unless these .vscode files are only tempoary and overwritten every time that a user starts the workspace on his own machine…

As we have all these environment variables availabe, how would you go about making the workspace accessible for multiple users, would you modify the setttings.json file and update the “C_Cpp.default.compilerPath” to (for example) ${platformio.packages_dir} /toolchain-gccarmnoneeabi @ 1.70201.0/bin ?

This would seem weird as platformio.ini should normally take care of that…

I have been caught up on this many times before, with IDEs that are built on Java. I was forced to run them locally on c:/, not even in my user directory which has a space in my name. After my computer crashed I could not restore the files because I had not committed them frequently enough to github. Well thanks for that!

I think that this is a nasty Java feauture, which is supposidly platform independent. I know that Linux cannot handle this, but why not updating this so that this thing is truelly paltform indpependent and run on any OS? Not everyone has the luxury to freely choose the OS that they are working with…

Having said that I see many references to my local directory in c_cpp_properties.json and other files, and the platormio (i.e Python) does not seem to have a problem with it…

in general what’s your reason/need to change env vars so special? Asking as maintainer of pioarduino and Platformio maintainer from project Tasmota.
Tasmota is everything else than a simple project, and there is no need for such special changes.
Probably you should have a look to refactor the Platformio setup in your project

The reason for this is very simple. I want to collaborate using the same folder on the network, so I want to use relative paths or paths that refer to the local user directory on the machine from which the workspace is started from. I have now included replaced all absolute paths references in platform.ini with ${platformio.packages_dir},

which seem to have the effect of updating all .json files within the .vscode folder on the network drive with the fully expanded local paths to the platformio packages, but that seems to be okay as the .vscode folder seens to be a) temporary and updated whenever a user opens the workspace and b) I have omitted them from git. This means that two users can collaborate in the same folder, albeit not at the same time -which is fine for now.

So I understand better now, it really seems that platform.ini is the only settings files that needs to be edited and that the toolchain directories do not have to be specifically stated as their location would be known to platformio…

Okay guys, thank you and Max a lot for your help, I finally feel like having regained control again.I consider this problem solved.

I wouldn’t share the folders. As you correctly wrote this will generate troubles when 2 or more accessing at the same time. I see no reason to do this.

it’s more of a handover…so it has to run on any machine.