PlatformIO not editing original files, moving them to a workspace

I have recently begun using PlatformIO instead of the Arduino IDE so I have several .ino files. These files are already in source control. I imported the .ino file with Import Arduino Project and happily started making changes. Then I went to commit the changes to source control and to my utmost surpise PlatformIO had copied the files into some workspace directory and it wasn’t editing my original files!

Why would it copy files? What is the point of an editor that doesn’t edit the files I open? Is there a way to keep it from copying the files and instead edit the original files? I can’t commit my changes to source control if it isn’t editing the original files in my working copy.

It copies those files because you tell it to… That’s the point of importing instead of “just opening”.

The editor (probably VSCode or Atom?!) edits the files you tell it to. In this case the files of the project you imported from Arduino IDE into a fresh PIO project.

You could manually create the file structure needed for a valid PIO project in the location of the original Arduino project and then commit those changes… but why would you. If you want to switch to PIO you should just initialize a new repo and handle it like a different project from that point on.
If all you want to do is use a different editor to modify your *.ino files you can open the *.ino in VSCode and upload with the Arudino IDE or use the Arduino extension for VSCode; no need to change your project into a PIO compatible one .

Overall you seem to get a few things wrong. By saying “Import Arduino Project” you tell PIO to create a new PIO project out of an existing Arduino project. That has to been done as PIO uses a different file structure compared to the Arduino IDE; the files considered part of your the project are quiet different if you compare an Arduino IDE project to a PIO project. You can initalize a new repository in the newly created PIO project folder and you will have source control for that project from that point on. Working with that new project you will of course always edit the files of that new project and not those of the old Arduino IDE project which you imported.

2 Likes