-
-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arduino-cli compile can no longer specify .ino file #765
Comments
Hi @janjongboom, It could be a regression, can you give us more details in order to reproduce the issue? |
@rsora I have a sketch folder (e.g. |
The folder containing the sketch must have the same name as the main For example, if you have a project like this:
all the .ino files are concatenated together in alphabetic order, except for the main file GPS_Tracker.ino that is always the first -> this is the reason why we need the containing folder to be the same name as the main sketch. Here you can find the relevant documentation about how a sketch structure https://arduino.github.io/arduino-cli/latest/sketch-specification/#primary-sketch-file It may be a problem to rename your folders or the sketch .ino so they match? |
@cmaglie I am trying to understand your arguments but if I specify directly what I want to compile as a cmd parameter I would expect compilation of that file and not getting error (Error during build: unable to find a sketch file in directory ...). I also experience troubles with your last changes. My project in Gitlab repository has different name than the main *.ino file. I was trying to use 0.10 version via install.sh script but this script checks for updates and install the 0.11 version anyway. It is also not good. If I use install script from version 0.10 I would expect that the 0.10 will be installed. But it is only my opinion... |
@xplsek01 I heard back from Arduino and you can get older versions through CDN. I had the same issue as you with the versions. Here are the links for 0.9.x (I assume 0.10 has similar ones):
|
@janjongboom and @xplsek01 |
I'd like to add that this whatever change caused this also seems to have broken other useful features. I used to have very good Eclipse IDE integration via a simple Makefile script that called the arduino-cli. In this scenario, the subdirectory was the same name as the main "sketch", but the main sketch had a .cpp extension, so that eclipse would handle it well and do all of the appropriate edit-time checking, etc. Now that is is broken and it claims it can't find a sketch. Not understanding why the default behavior can't be as described -- subdir name same as the sketch, with an extension of ".ino", but more advanced users can specify other parameters (that USED to work just fine). Happy to provide a copy of my Makefile if that would help. |
Another vote here for specifying the file to be complied. I don't even use .ino files, since they break compatibility with editors that know how to handle .cpp files. Previously it worked just fine for those that provided their own main.cpp file rather than relying on the .ino wrapper. |
The easy workaround for third-party IDE integration as described above would be to add an empty .ino file matching the directory name, to indicate to arduino-cli that this is indeed an Arduino sketch, but then just keep all your code in .cpp files so you can edit those files with your IDE optimally. |
Also note that the change mentioned in the first post seems like a regression in Of course, the notion of what constitutes a sketch can be changed in all Arduino tools, see #948 for discussion about this. |
Just came across this regression myself. The offending code is here: Prior to this, a full sketch path (including Can this be fixed? |
@thegecko
https://arduino.github.io/arduino-cli/latest/sketch-specification/ |
So this behavior broke again in the 0.13 release. As we have zero control over the folder name where the
I realize that this is technically not a 1.0 release of the CLI, but the constant breaking of the API is very annoying as there's zero heads-up on our end and the only way we realize this is from complaining customers. |
Using `--input-dir path/to/firmware` with a directory containing: path/to/firmware/firmware.ino.bin path/to/firmware/some_other_firmware_name.ino.bin should not fail but select `firmware.ino.bin` for upload because the containing folder has the same name. See arduino#765 (comment)
Using `--input-dir path/to/firmware` with a directory containing: path/to/firmware/firmware.ino.bin path/to/firmware/some_other_firmware_name.ino.bin should not fail but select `firmware.ino.bin` for upload because the containing folder has the same name. See arduino#765 (comment)
* Sligthly simplified upload test cases handling * Make --input-dir handle gracefully some rare cases Using `--input-dir path/to/firmware` with a directory containing: path/to/firmware/firmware.ino.bin path/to/firmware/some_other_firmware_name.ino.bin should not fail but select `firmware.ino.bin` for upload because the containing folder has the same name. See #765 (comment)
I find this requirement confusing as well. If we explicitly specify a different file, why not use that as the base file? It took me hours today till I finally figured out the error. (as an aside: why not add a message to the not found error, saying something like do you have a file named the same as your repo?) |
@electronicsguy are you using the latest release of the CLI? It seems to work correctly for me on Linux.
The only issue that I know of with |
@silvanocerza I suspect that @electronicsguy means a sketch with multiple .ino files e.g. @electronicsguy I think the reasoning for the current behavior is that a sketch is now compiled in the same way regardless of how you specify the path to the sketch (remember that the sketch is the directory, not just a single .ino file). So it seems that there is a tradeoff between your surprise (When I specify a .ino file, I am surprised that another .ino file is taken as the primary file) vs the surprise that would be introduced when your suggestion is implemented (When I specify another .ino file within the same sketch, the sketch compiles differently or fails to compile). |
That works too:
As @matthijskooijman says the Sketch is the directory, not a single See the Sketch Specification docs: |
@silvanocerza do you still have a dummy MySketch.ino there? If so yes it'll work. It won't without it, though AFAIK. |
@matthijskooijman Yes, I see the reasoning behind dumbing down things for beginners. Wonder why it can't understand that we have provided a file explicitly, so just use that. |
@electronicsguy I thought you were arguing that a file that has two files (e.g. MySketch.ino and MySketch2.ino) would be compiled differently depending on which file you pass to arduino-cli, but now I think you are arguing that it should be possible to omit MySketch.ino, right? IOW, to have a sketch where there is no .ino file named after the directory? If the latter, I suggest chiming in at #948 which was specifically opened for that discussion.
Maybe this part is still good to discuss here, but it seems that in a quick test (with git master version of arduino-cli), the error message seems ok already?
But maybe I'm doing something different than you meant? |
@matthijskooijman You understood correctly. Apologies if I was vague. Yes, I do mean having a sketch directory without a file with the same name. I guess it's ok to do it so, it just wasn't clear to me when I got the error. The error message simply says "no valid sketch found". Unless I go through the spec which says it must be so, I had no idea that you needed to have a file with the same name as the sketch. It was only when I was using arduino-cli in github-ci that this error was exposed. This is not a requirement when using standalone Arduino IDE. |
Yes, there have been some enhancements in certain errors reporting, there's still lots of improvements we can do to show clearer errors to users, we're working on it though. By the way as of now there are no plans on changing the Sketch main file specification, I understand it creates confusion but it's not our main focus right now. Compilation works so am happy with it, we'll see in the future. |
This is a universal requirement across all official Arduino development software. If you attempt to open Matthijs's sketch in the Arduino IDE, you will get a dialog:
|
I guess it's somewhat unrelated to the original problem, but since this has been mentioned here and since I wanted to have it as .cpp files as well, this of how it works now:
I can't call that folder src because it compiles it recursively and prevents me from getting includes to work the way I want it. Docs: https://arduino.github.io/arduino-cli/0.21/sketch-specification/#src-subfolder. "It can be used to bundle libraries with the sketch in order to make it a self-contained project.", then why is it not called "lib"... |
Bug Report
Current behavior
On v0.9 of the CLI we can compile a specific ino file via:
On v0.11 this fails with:
And there seems no way to specify the
.ino
file anymore. Is there any replacement?Environment
arduino-cli version
): arduino-cli Version: 0.11.0 Commit: 0296f4dThe text was updated successfully, but these errors were encountered: