Beware Onedrive and file sharing

I had a PC happily running sketches for years and apart from Windows 10 updates, left it to it's own devices.

I needed to update a sketch that previously had been and still was working fine.
When I made one small change and tried to compile it, it failed at the first included library.
So commented that out.

Then onto the next and so on. It was coming up "file not found" or "library does not exist".
I did find them in file explorer, but now they were in the Onedrive Documents folder.
I can only think this might have happened during a trial backup to Onedrive.

Normally, I backup to a local NAS RAID setup, but mistakenly thought that having a cloud backup might be better (a previous NAS, Synology, had crashed both Seagate drives).

Now I have the task of unravelling this mess.

Fortunately, another PC does not have any of the Arduino stuff on Onedrive and running the failing sketches on that had no problems.

The libraries included with the IDE in the IDE program location were not affected.
I'm looking for a quick fix before getting rid of the Onedrive connection.

  1. Could I change the sketchbook location from the default in Preferences to the Onedrive location, or would that be inviting more trouble?

  2. Could I add the relocated libraries directly to the sketches as tabs? I might have done it before but can't find where.

A typical missing library is AltSoftSerial.h.
How much of the library folder would need to go into the tab or tabs and would it need structuring like a void() function?

I think that about half a dozen libraries are affected and the sketch is pretty large with quite a few tabs already and will only run on a Mega 2560.


It's worth a try. Just make sure you have everything backed up and then see what happens.

I don't recommend doing this solely as a workaround for your system being messed up. There are specific cases where it makes sense to bundle libraries with a sketch, but it also can be very inconvenient and increase the complexity of a project. So only do it if you have a real need.

I think you're better off spending your time trying to fix whatever is broken on your system.

Any library you want to bundle with the sketch.

Some libraries do need to be modified in order to be bundled with a sketch. Let's say you have a library like this:

|_ SomeHeader.h
|_ SomeSource.cpp

And in SomeSource.cpp the library author did this silly thing:

#include <SomeHeader.h>

Although not really correct, when the library is installed normally, that works fine. But when the library is bundled with a sketch you must use the appropriate relative paths for the #include directives of local files:

#include "SomeHeader.h"

An easy enough fix to do, but sort of annoying and you'll need to repeat it every time you update to a new version of the library. I have found the use of inappropriate #include syntax to be relatively common in the Arduino world.

Things get even more tricky when you have a library with a nested folder structure. Unlike a flat library structure, you can not just dump these into the root of the sketch folder. You can put them under the src subfolder of the sketch though if you like:

Thanks pert.
I'm tinkering right now.
I chose an easy library like RTClib.h and copied into a new sketch tab I labelled as RTClib.h as it doesn't have other libraries included within it.
It didn't compile at first, but changing <> to "" fixed that.
So a step forward.
Does it need anything else from the RTClib folder, like cpp, keywords etc.?
I absolutely agree that fudging around what is a Onedrive problem, or at least, nothing I consciously did, isn't the right way.
But right now, an important sketch works, but changes etc. are stuffed as it won't compile.
It's way, way too big to include the code and I wouldn't inflict it on anyone.
Right now, I'm peed off that after quite a few years tinkering with Arduino, some Windows feature has highjacked my files and time that I really can't afford has to be spent unravelling this.
A chunk of time has already gone in trying to workout what all the little icons in file explorer mean, but if I do fix it, I won't go near it again.


keywords.txt is used to define the keywords of the library that should be highlighted in special colors in the Arduino IDE. keywords.txt will not be recognized in the sketch folder, so there is no point in copying it over, and you will not get keyword highlighting for libraries bundled with the sketch. But this is a purely cosmetic feature that will have no effect on the library's actual functionality.

There have been quite a few reports of problems with OneDrive and Arduino IDE over the years since Microsoft released this feature. However, they were mostly all years ago. Even though I have no interest in using it, I'm sure a lot of other Arduino users have OneDrive and are able to use it with the Arduino IDE. So it must be possible. Are you using the latest Arduino IDE 1.8.15?

IDE version?
I do check regularly, but am still on 1.18.13.
I'll fix that straightaway.
If I do get it work with OneDrive, I'll let you know.
If I can get it back to it's old self, that will be a relief.
Over the years, I should have not been surprised when yet another snag crops up and I dread to think how much time has gone into fixing stuff.
At least it wasn't Colonial Pipeline.

I can see what it has done.

The whole Documents folder that used to be in C:\Users\me\Documents\Arduino

Is now C:\Users\me\OneDrive\Documents (Haswell)\Arduino

That's cheeky. It's got to be down to using OneDrive for backup

All OK, sketches compiling using the OneDrive location and no missing libraries.
That will do for now and gives me time to restore the Documents folder to its rightful place.

I'm very glad to hear it's working now!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.