arduino / arduino-cli

Arduino command line tool
https://arduino.github.io/arduino-cli/latest/
GNU General Public License v3.0
4.4k stars 384 forks source link

Upload Uses Wrong Directory #2053

Open weswitt opened 1 year ago

weswitt commented 1 year ago

Describe the problem

After compiling attempting an upload fails with "Error during Upload: Compiled sketch not found in C:\Users\wesw\AppData\Local\Temp\arduino-sketch-A1E8FD2B951BC0178B8D63295C7E129C".

This fails because there is no directory named arduino-sketch-A1E8FD2B951BC0178B8D63295C7E129C. The compiled sketch is in arduino-sketch-BD62D8498EB4D4F7E3207A44BF823043.

Where does arduino-cli get the directory name from?

To reproduce

arduino-cli.exe upload --verbose --fqbn esp8266:esp8266:d1_mini -p COM4

Expected behavior

The sketch is uploaded.

Arduino CLI version

0.29.0 Commit: 76251df9 Date: 2022-11-17T09:21:37Z

Operating system

Windows

Operating system version

11

Additional context

No response

Issue checklist

weswitt commented 1 year ago

ok, found the solution. if i add ".\" at the end of the command it works.

so it seems that the tool does in fact work correctly, but the documentation and the help text for the tool should be updated to reflect this.

per1234 commented 1 year ago

Hi @weswitt. Thanks for your report.

Where does arduino-cli get the directory name from?

It is the MD5 hash of the sketch path:

https://github.com/arduino/arduino-cli/blob/0.29.0/arduino/sketch/sketch.go#L313-L323

if i add "." at the end of the command it works.

so it seems that the tool does in fact work correctly, but the documentation and the help text for the tool should be updated to reflect this.

The sketch path argument is optional. If you do not provide it, the current working directory is used. So it should not be necessary to add . as that argument. If Arduino CLI is calculating a different build folder name when compiling than it does when uploading, this is a bug.

I was not able to reproduce this fault so I'll need some more information from you in order to proceed with the investigation:

First of all, please download the latest nightly build and then comment here to say whether the fault still occurs. Make sure you run an arduino-cli compile command in your sketch before doing an arduino-cli upload command. This is required because the temporary build paths have been moved to a new location (https://github.com/arduino/arduino-cli/pull/2031) since 0.29.0 and the nightly version of Arduino CLI will not be able to find the build you produced when you ran arduino-cli compile using Arduino CLI 0.29.0.

There has been a significant amount of development work on Arduino CLI since the time of the 0.29.0 version you are using, including some changes to relevant code. The nightly build download links are listed here:

https://arduino.github.io/arduino-cli/dev/installation/#nightly-builds

weswitt commented 1 year ago

yes i already tried with the nightly build

per1234 commented 1 year ago

Does the fault still occur after you use the nightly build to run an arduino-cli compile followed by an arduino-cli upload command without a sketch name argument @weswitt?

cmaglie commented 1 year ago

Maybe we could hint in the error message to run a compile before the upload.

weswitt commented 1 year ago

tried this and it also does not work

per1234 commented 1 year ago

@weswitt please post the output you get from running the pwd command from the terminal in the folder you are running the arduino-cli commands from.

Is there anything special about this path (e.g., network share, junction, symlink, ect.)?

weswitt commented 1 year ago

this is on windows so there is no pwd command. and no there is nothing special about this dir.

per1234 commented 1 year ago

this is on windows so there is no pwd command

Please, work with me here. Getting information from you is going really slowly.

Which shell are you using?

Windows PowerShell does have a pwd command:

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-location?view=powershell-7.3#notes

If you are using cmd, then post the output of the cd command.

there is nothing special about this dir.

Does the problem also happen if you create a new sketch in a different location and try the same sequence of arduino-cli compile, arduino-cli upload commands?

weswitt commented 1 year ago

i'm using cmd inside of a terminal host.

cd: d:\dev\src\homeauto\weather\waterflow\test32

i can try to make a new sketch later today, but regardless there seems to be a bug

weswitt commented 1 year ago

i just tried your test of making a simple sketch in a new dir. same failure

weswitt commented 1 year ago

i moved the dir with the sketch to the root of the drive and it works. so clearly arduino-cli has an issue with the dir name or something else about the location

cmaglie commented 1 year ago

@weswitt we cannot figure out the problem nor we are able to reproduce it, we need more info.

Could you please run the compile and upload with the -v flag and paste here the full output?

arduino-cli.exe compile -v --fqbn esp8266:esp8266:d1_mini
arduino-cli.exe upload --verbose --fqbn esp8266:esp8266:d1_mini -p COM4