How to run PlatformIO without installing it?

How can one run the PlatformIO CLI engine without installing anything?

1. Context

Let me first sketch the context. As cofounder of Embeetle IDE (https://embeetle.com), I’m trying to integrate PlatformIO into our IDE. Embeetle has its own way to deal with various tools:

  • Tools found on the $PATH are made accessible.
  • Other required tools are offered for download.

Those offered for download are just downloaded into a folder without modifying anything on your system. In other words: Embeetle keeps your system clean by avoiding “tool installations”. Because we don’t put tools on the $PATH, Embeetle always invokes tools by their absolute paths. This approach works remarkably well for all our tools so far:

2. The case for PIO

Let’s now jump to PlatformIO. Basically, PlatformIO will be a tool in the “Build Automation” category. Granted, it’s doing more than just build automation, but we have to choose a category to put it in.

In case the user already has PlatformIO on his system (more in particular the PlatformIO CLI engine), Embeetle will recognize that and make it available. Case closed.

There’s a problem for users that have no PlatformIO CLI yet. Embeetle would then offer a download of the PlatformIO CLI tool and put it in a folder alongside the other tools. Typically, that would be in a folder like:
<embeetle_installation>/beetle_tools/linux/pio_5.2.3_32b

Now it occurs to me that PIO depends on some system settings (perhaps the $PATH?) I moved my current '~/.platformio' folder into my Embeetle installation folder, and then tried to invoke the /bin/pio file. This is what I get:

# Invoke PIO CLI engine with its absolute path
$ /home/kristof/EMBEETLE_IDE/embeetle/beetle_tools/linux/pio_5.2.3_32b/bin/pio --version

bash: /home/kristof/EMBEETLE_IDE/embeetle/beetle_tools/linux/pio_5.2.3_32b/bin/pio: /home/kristof/.platformio/penv/bin/python: bad interpreter: No such file or directory

As you can see, the CLI engine looks for a python interpreter in the old location '/home/kristof/.platformio/penv/bin/python' even though that’s empty. It should instead look into the same folder where the CLI engine itself is located. Then it could find it at: '/home/kristof/EMBEETLE_IDE/embeetle/beetle_tools/linux/pio_5.2.3_32b/bin/python'

3. Questions

So everything considered, I would like to ask:

How can one run PlatformIO without modifying anything on the system?

I’m tagging @maxgerhardt, @ivankravets and @valeros because I’m in contact with them regarding the PlatformIO integration into Embeetle IDE.

PlatformIO manages everything it needs in a single folder, including a penv for Python packages. All you need is set the PATH to include ~/.platformio/penv/bin/. It’s well-documented, there’s no need for a different way to manage tools & applications.

Your question is confusing. PIO self-manages several GB of toolchains and libraries, there’s no way to “not modify anything”. And it’s already in one well-defined area (bravo, BTW).

In short: there’s ~/.platformio/ and there’s one extra entry in PATH. It Just Works.

1 Like

Thank you @jcw for your reply.

That’s great. One problem I do experience is this: as soon as I added ~/.platformio/penv/bin/ to my PATH variable, my shells always launch python from that location:

$ which python3
~/.platformio/penv/bin/python3

While before I had:

$ which python3
/usr/bin/python3

So my solution would be to add ~/.platformio/penv/bin/ at the end of my $PATH, such that my shells still launch python from /usr/bin/python3. However, then I get the error 'bad interpreter' when launching PIO.

Try ls -l ~/.platformio/penv/bin/python3 sometimes, at least on my Linux system, that’s just a sym link to the installed python3 interpreter. Just a thought.

Cheers,
Norm.

There is a good explanation in docs on how to use PlatformIO Core with other IDEs/Plugins. See
https://docs.platformio.org/en/latest/core/installation.html#integration-with-custom-applications-extensions-plugins

Embeetle is free to use. It is not open source.

Sad.

Hi @vazhnov ,
If we can get funding, we could opensource it.

1 Like