PIO Core: build offline (w/o Internet connection)

Maybe I’m not the first one asking this. I have seen similar questions here but no real answer.

I know PIO Core checks every time you run it for updates or whatever. That’s cool if you have Internet connection 'cause you are always up to date.

But sometimes you don’t. Because you are on a roof top or you are “out in the field”, connected to the device you are trying to flash via WIFI and my laptop does not have two wifi interfaces… For several reasons, I would like to be able to build and flash via OTA a device when I don’t have Internet connection.

And I don’t need it because I’m just bug fixing a given code base, I don’t want to update libraries, frameworks, platforms… at that moment. I just want to change a setting, build and flash.

So it would be cool to have a way to bypass the ping to your server and trust what you have locally.

Do you use the latest version of PIO Core? It should be fixed in 3.5.0 version.

I’ve been investigating further. Take this project:

[env:d1_mini]
platform = https://github.com/platformio/platform-espressif8266.git#v1.5.0
board = d1_mini
framework = arduino
build_flags = -g -DMQTT_MAX_PACKET_SIZE=400 ${env.ESPURNA_FLAGS}
lib_ignore =
lib_deps =
    Brzo I2C
    https://github.com/krosk93/espsoftwareserial#a770677
    https://github.com/marvinroger/async-mqtt-client#v0.8.1
extra_scripts = extra_scripts.py

I build the project with internet connection, then I disconnect from the Internet and build it again. It fails with “Error: You are not connected to the Internet. If you build a project first time, we need Internet connection to install all dependencies and toolchain.”.
But then if I remove the async-mqtt-client dependency it works!

Trying with a bigger project (ESPurna) with several dependencies in the lib_deps it works if I comment out the async-mqtt-client and the fauxmoESP libraries:

#    https://github.com/marvinroger/async-mqtt-client#v0.8.1
#    https://bitbucket.org/xoseperez/nofuss.git#0.2.5

If I do so it compiles successfully since those libraries are actually on .piolibdeps. If I enable them it fails…

Thanks! I significantly improved a work in off-line mode in the latest development build. Please run pio upgrade --dev. Does it work now good in off-line mode?

Great!

Sorry for the late reply. Just tested 3.5.1a7 and works a charm in offline. No changes to the project configuration.

Thank you very much!

1 Like

I’m having this exact same problem. I’m on version 5.1.0, but I can’t figure out how to tell PIO that I want to work in “off-line mode”. Is it a setting? A configuration? A command line? How do I do it? When I don’t have Internet, I can’t use PIO. Thanks! (I use PIO as a VS Code Extension, running on Linux Mint 19.)

To the best of my knowledge it’s not a setting - merely PlatformIO detecting that you don’t have an internet connection, and skipping checking for updates.

I haven’t tried recently, but as long as all the dependencies are present (toolchain, libraries, etc), I didn’t have any issues with using PlatformIO offline / with no internet.

Is your scenario easily reproducible? i.e. does it fail to work with a simple blink program, on a platform that you’ve used before (so the toolchain files should all be present)? Or is it a project with specific library dependency requirements… i.e. the issues mentioned earlier seemed to partly be in conjunction with git managed depenencies.

I haven’t tried it with a simple program with no external library dependencies. (I work only on a small number of open source projects, so I don’t have a LOT of PIO experience.) As I’m typing this, I have a terrible Internet connection, and I’m seeing two things when I start PIO:
In the “Output” tab:

Installing PlatformIO IDE...
It may take a few minutes depending on your connection speed
Please do not close this window and do not open other folders until this process is completed.

And in a little window in the lower right corner: PlatformIO Installer: Downloading portable Python interpreter.

I was working in PIO last night - why is it “Installing PlatformIO IDE” from some online source, and “downloading a portable Python interpreter” now, just a few hours later? It’s as if it thinks I want to update everything every time I start PIO.

It just now finished, and I see this in the Output tab:

PlatformIO IDE installed successfully.

Please restart VSCode.

So what did it just have to install that requires a VSCode restart?

Most likely the PlatformIO VSCode extension auto-updated (and triggered the PlatformIO core to update also). Which is the main reason you need to restart VSCode (so that the extension can reload). If you had bad internet, you probably want to turn VSCode’s extension auto-update off, and also PlatformIOs, and manage updates manually.

image

The PlatformIO core (“PlatformIO CLI”) does have an update check interval, which is by default every three days, but I think that is only used to show a notice that a new version is out, and doesn’t update on it’s own. You can see this if you run pio settings get from a PlatformIO terminal in VSCode, and change the value using pio settings set check_platformio_interval new-value

@pfeerick, thank you! I have made those changes. I hope that keeps PIO from not working the next time I have no Internet.