Project Include Errors

I started a project on my desktop, saved it on OneDrive, then opened it on my laptop. I made sure I set the project directory as always store on this device. It looks as though everything is ok other than an include error on #include <OneWire.h>.
image

Here is my platormio.ini:

[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
framework = arduino
lib_deps = 
	adafruit/DHT sensor library@^1.4.2
	knolleary/PubSubClient@^2.8
	robtillaart/DS18B20@^0.1.10

I even tried to reinstall DS18B20 with pio lib install "robtillaart/DS18B20@^0.1.10" but that just tells me it’s already installed:

pio lib install "robtillaart/DS18B20@^0.1.10"
Library Storage: ...Monitor\.pio\libdeps\esp-wrover-kit
Library Manager: DS18B20 @ 0.1.10 is already installed

In the “problems” output I see:

{
	"resource": ".../src/main.cpp",
	"owner": "C/C++",
	"code": "1696",
	"severity": 8,
	"message": "#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (...\\src\\main.cpp).",
	"source": "C/C++",
	"startLineNumber": 6,
	"startColumn": 1,
	"endLineNumber": 6,
	"endColumn": 21
}
{
	"resource": ".../src/main.cpp",
	"owner": "C/C++",
	"code": "1696",
	"severity": 8,
	"message": "cannot open source file \"OneWire.h\"",
	"source": "C/C++",
	"startLineNumber": 6,
	"startColumn": 1,
	"endLineNumber": 6,
	"endColumn": 21
}

I’m out of ideas, anyone else using OneDrive to have projects on multiple computers?

Does the project compile when you hit “Build”?

No, I get this:

*** [.pio\build\esp-wrover-kit\lib541\DS18B20\DS18B20.cpp.o] Error 1
src\main.cpp:6:21: fatal error: OneWire.h: No such file or directory

Try explicitly adding

     paulstoffregen/OneWire @ ^2.3.5

to the lib_deps list and rebuild.

Yep, that worked. Thanks!

Any reason this didn’t just work like it did on my desktop pc?

Either OneWire was a globally installed library on your desktop PC (C:\Users\<user>\.platformio\lib) or magically when you added the libraries in the project on your desktop PC it did install the dependency. No idea.

I don’t see it globally installed at C:\Users\<user>\.platformio\lib

Excuse my ignorance here, I just started using PlatformIO. I was looking at the robtillaart/DS18B20 library and I don’t see that it lists dependencies. I see that some other libraries list dependencies, so should I raise an issue on the library, or is the user generally expected to resolve dependencies?

The strange thing is, back on my desktop, I removed the onewire library, removed the dependency from platformio.ini, and now it won’t compile on my desktop any more. I’m not sure what has changed on my side. The last library update was over a month ago, so I’m stumped.

Edit:
Also, I’m a little confused on the library dependencies. The other library I have just lists a name (ex. Adafruit Unified Sensor) instead of a user/library@version format like platformio.ini. How does this work?

I’ve already opened the PR Declare OneWire dependency by maxgerhardt · Pull Request #14 · RobTillaart/DS18B20_RT · GitHub so this should get resolved.

Over the time (“historically grown”) there were many ways through which libraries could be declared. You also see this in the documentation. The oldest one is “library ID”, e.g., https://platformio.org/lib/show/1/OneWire has ID 1. The next one besides that was “library name”, e.g., “OneWire”. This lead to the problem that people could have forks of libraries that used the same name, and also versioning was missing. So now we’re at owner/libraryname @ semantic_version, which fullfills all needs and should always be the used format. The library registry (https://platformio.org/lib) also gives installation instructions in that format.

1 Like