Compiling for ESP32 fails: "Access is denied."

Hello, I am new here.
Since the update I can't compile ESP32 anymore.

Error message: (in German)

Zugriff verweigert

exit status 1

Compilation error: exit status 1

I installed the IDE2.1.1 on another computer and created a new sketch. The same problem appears.

@michl73

Check your anti-virus logs and settings as well as the permissions directories.

If you enable verbose output during compilation, you can exactly find which directories and files are accessed and take it from there.

Hello, thanks for the quick reply.

the output is:

FQBN: esp32:esp32:esp32
Using board 'esp32' from platform in folder: C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10
Using core 'esp32' from platform in folder: C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10

cmd /c if exist "C:\Users\Michael Glier\AppData\Local\Temp\.arduinoIDE-unsaved2023619-11812-18nnsgp.8ckqk\sketch_jul19b\partitions.csv" COPY /y "C:\Users\Michael Glier\AppData\Local\Temp\.arduinoIDE-unsaved2023619-11812-18nnsgp.8ckqk\sketch_jul19b\partitions.csv" "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\partitions.csv"
cmd /c if not exist "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\partitions.csv" if exist "C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10\variants\esp32\partitions.csv" COPY "C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10\variants\esp32\partitions.csv" "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\partitions.csv"
cmd /c if not exist "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\partitions.csv" COPY "C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10\tools\partitions\default.csv" "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\partitions.csv"
1 Datei(en) kopiert.
cmd /c IF EXIST "C:\Users\Michael Glier\AppData\Local\Temp\.arduinoIDE-unsaved2023619-11812-18nnsgp.8ckqk\sketch_jul19b\bootloader.bin" ( COPY /y "C:\Users\Michael Glier\AppData\Local\Temp\.arduinoIDE-unsaved2023619-11812-18nnsgp.8ckqk\sketch_jul19b\bootloader.bin" "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\sketch_jul19b.ino.bootloader.bin" ) ELSE ( IF EXIST "C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10\variants\esp32\bootloader.bin" ( COPY "C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10\variants\esp32\bootloader.bin" "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\sketch_jul19b.ino.bootloader.bin" ) ELSE ( "C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.5.1/esptool.exe" --chip esp32 elf2image --flash_mode dio --flash_freq 80m --flash_size 4MB -o "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\sketch_jul19b.ino.bootloader.bin" "C:\Users\Michael Glier\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10\tools\sdk\esp32\bin\bootloader_qio_80m.elf" ) )
esptool.py v4.5.1
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
cmd /c if exist "C:\Users\Michael Glier\AppData\Local\Temp\.arduinoIDE-unsaved2023619-11812-18nnsgp.8ckqk\sketch_jul19b\build_opt.h" COPY /y "C:\Users\Michael Glier\AppData\Local\Temp\.arduinoIDE-unsaved2023619-11812-18nnsgp.8ckqk\sketch_jul19b\build_opt.h" "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\build_opt.h"
cmd /c if not exist "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\build_opt.h" type nul > "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA\build_opt.h"
Zugriff verweigert
cmd /c type nul > "C:\Users\Michael" "Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA/file_opts"

exit status 1

Compilation error: exit status 1

I installed the software on a virtual machine for testing. In the board manager ESP32 by Espressif installed, the ESP32 Dev Module selected. The same problems occur.

Hello, i think the problem is in the last line:

cmd /c type nul > "C:\Users\Michael" "Glier\AppData\Local\Temp\arduino\sketches\BCC6D161902E6D97CFF1F1190C34FFBA/file_opts"

could it be due to the space in your User home directory filename?

Yes, correct. How can I change this without changing my username?

Unfortunately I don't think it's possible as it's part of the absolute path used in various scripts - but may be it's not the cause of the issue (it could if the file path is not escaped in the right way and thus the cmd is interpreted in two parts and the filename is wrong)

you could try to see if this is the issue by creating a temp user without any space and see if the compile process still has some issues

I just tested it with a new user named "Tempuser". Then everything runs perfectly.

The Error is a space in my Username.

The compiler writes:

cmd /c type nul > "C:\Users\Michael" "Glier\AppData\Local\Temp\arduino\sketches\925B853CE76FCD073FEC76814EEE6C3C/file_opts"

but correct its (i think so):

cmd /c type nul > "C:\Users\Michael Glier\AppData\Local\Temp\arduino\sketches\925B853CE76FCD073FEC76814EEE6C3C/file_opts"

How i can modify it?

OK - so I think you got the issue there

it's not the first time (Upload fails if path contains a space · Issue #958 · arduino/arduino-cli · GitHub)

Thank you.

Do I have any change to fix the problem?
I think I am not the only one with spaces in the username.

Before the update of Arduino IDE I had no problem.

worth reporting on gitHub

I'm having the same problem. New issue opened on gitHub
https://github.com/arduino/arduino-ide/issues/2147

The problem is with the new updated board manager 2.0.10 of esp32 which throws error. I fixed it by pasting "https://dl.espressif.com/dl/package_esp32_index.json" in the Additional Boards section in preferences and changing it to 1.0.6.

It took me 5 hours to figure out the issue. Hopefully the bug gets fixed, till then use earlier version 1.0.6 of esp32

Your fix is far in excess of what is necessary. The regression was introduced in the 2.0.10 release, so you can simply roll back to the previous version (2.0.9) instead of going all the way back to the antiquated 1.0.6.

Even if you did want to use 1.0.6 for some reason, it is not necessary to change your "Additional Boards Manager URLs" preference in order to accomplish that. All the releases are available from the maintained URL specified in the official installation instructions for the "esp32" boards platform:

https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-arduino-ide

You can simply select the version you want from the menu in the Arduino IDE Boards Manager.

It has already been fixed:

That fix will be in the next release of the "esp32" boards platform. If you are using the maintained URL in your "Additional Boards Manager URLs" preference, Arduino IDE will notify you once that release is available.

If you want the fix now, you can apply it manually to your existing installation. I can provide instructions for doing that if anyone is interested.

1 Like

OK, I have spent most of the day chasing what appears to be this "space in user name" fiasco.
I have uninstalled, reinstalled, all the usual Windows stuff. Rebooted, etc. version 1.18 worked OK.
Moving back to 2.0.9 solved the "access is denied problem. Now, I can get back to rebuilding everything I destroyed along the way. My big mistake--accepting an "upgrade". One of those things--I had just made some changes, then accepted the upgrade. Assumed it was something I did. Which is usually the case.

"If you want the fix now, you can apply it manually to your existing installation. I can provide instructions for doing that if anyone is interested.".

Count me as one who would like said instructions. I do like to keep stuff up to date.

Pardon my grumpy tone. This forum and this topic brought me back from the edge of self diagnosed insanity. Thanks.

I have the same problem - thank you for the backdating solution

I'd be interesting in knowing how to apply the manual fix

OK, here you go:

  1. Use Arduino IDE Boards Manager to install version 2.0.10 of the esp32 boards platform if you already rolled back to a previous version.
  2. Select File > New Sketch from the Arduino IDE menus.
  3. Select any ESP32 board from the Arduino IDE Tools > Board menu.
  4. Select Sketch > Verify/Compile from the Arduino IDE menus.
  5. Wait for the compilation to finish.
  6. Scroll the black output panel at the bottom of the Arduino IDE window all the way up to the top.
  7. Look for the line that starts with "Using board ...".
    For example:
    Using board 'esp32' from platform in folder: C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.10
    
  8. Use any text editor to open the file platform.txt that you find under the path shown in that line of the compilation output.
  9. Change line 192 of platform.txt from this:
    recipe.hooks.core.prebuild.set_core_build_flag.pattern=bash -c "echo '-DARDUINO_CORE_BUILD' > {file_opts.path}"
    
    to this:
    recipe.hooks.core.prebuild.set_core_build_flag.pattern=bash -c "echo -DARDUINO_CORE_BUILD > {file_opts.path}"
    
  10. Change lines 195-197 from this:
    recipe.hooks.prebuild.set_core_build_flag.pattern.windows=cmd /c type nul > {file_opts.path}
    recipe.hooks.core.prebuild.set_core_build_flag.pattern.windows=cmd /c echo "-DARDUINO_CORE_BUILD" > {file_opts.path}
    recipe.hooks.core.postbuild.set_core_build_flag.pattern.windows=cmd /c type nul > {file_opts.path}
    
    to this:
    recipe.hooks.prebuild.set_core_build_flag.pattern.windows=cmd /c type nul > "{file_opts.path}"
    recipe.hooks.core.prebuild.set_core_build_flag.pattern.windows=cmd /c echo "-DARDUINO_CORE_BUILD" > "{file_opts.path}"
    recipe.hooks.core.postbuild.set_core_build_flag.pattern.windows=cmd /c type nul > "{file_opts.path}"
    
  11. Save the file.
  12. Select File > Quit from the Arduino IDE menus.
  13. Start Arduino IDE.
    Restarting Arduino IDE is necessary to cause it to recognize the changes you made to the platform.txt file.

Now try compiling your sketch for an ESP32 board again. Hopefully this time the "Access is denied" error will no longer occur.

3 Likes