arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

Upload Uses Wrong Directory

Open weswitt opened this issue 2 years ago • 13 comments
trafficstars

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

  • [X] I searched for previous reports in the issue tracker
  • [X] I verified the problem still occurs when using the nightly build
  • [X] My report contains all necessary details

weswitt avatar Jan 26 '23 16:01 weswitt

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.

weswitt avatar Jan 27 '23 17:01 weswitt

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

per1234 avatar Jan 28 '23 11:01 per1234

yes i already tried with the nightly build

weswitt avatar Jan 28 '23 16:01 weswitt

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?

per1234 avatar Jan 28 '23 16:01 per1234

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

cmaglie avatar Jan 30 '23 09:01 cmaglie

tried this and it also does not work

weswitt avatar Jan 31 '23 15:01 weswitt

@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.)?

per1234 avatar Jan 31 '23 16:01 per1234

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

weswitt avatar Jan 31 '23 16:01 weswitt

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?

per1234 avatar Jan 31 '23 16:01 per1234

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 avatar Jan 31 '23 16:01 weswitt

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

weswitt avatar Jan 31 '23 18:01 weswitt

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

weswitt avatar Jan 31 '23 18:01 weswitt

@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

cmaglie avatar Jun 09 '23 09:06 cmaglie