Specifying Documents Folder when Compiling with Arduino CLI

I'm attempting to use Arduino CLI on a Windows Build Server (Windows Server 2022 Datacenter Azure Edition) to compile some Arduino code. My Arduino code is hosted in Github, and I have a YAML file/Github Action configured such that a build is kicked off on this Windows server whenever I merge into my target branch.

Whenever I get to a step in my Github Actions that involves the Arduino CLI, I see: Unable to get Documents Folder: The system cannot find the file specified.

Qsbuz4an

This screenshot shows the step where I install the ESP32 Core libraries, but all other steps involving arduino-cli produce this same message.

I understand that the arduino-cli is attempting to find my Documents folder. When I connect to my build server manually and execute an arduino-cli command as my local admin, I do not see this message. Apparently, my Github Action is running as nt authority/system, so it makes sense that arduino-cli is not able to find a Documents folder while running as this user. My question is: Is there a way to manually specify a "Documents" folder for the Arduino-CLI? If not, is there a way to execute as a different user?

I'm running 64bit Arduino CLI, Version 1.0.1.

I've moved your topic to a more suitable location on the forum. In my view, this is not so much a programming question but more a question about how to use the tools.

Hi @jobrien9. Arduino CLI's configuration system is documented here:

https://arduino.github.io/arduino-cli/latest/configuration/

The "Documents" folder is used in the default location of the directories.user configuration key.

Unfortunately the last time I checked I found that Arduino CLI always queries Windows for the user "Documents" folder path even if you have set a custom value for directories.user. But that was some time ago and there have been significant changes in Arduino CLI so maybe the situation has changed since that. Worth a try.

If that fails, you should look into finding a way to configure Windows so that it will provide a Documents folder path when queried.

Is there a reason you are using a Windows machine? Why not using a Linux runner machine instead?

Thanks for the reply! I gave the "directories.user" fix a try but didn't have any luck there.

Ultimately, I ended up changing the user who executes my YAML script to a more "normal" user (i.e. not the System user). I documented the details of how I did that here. In short, I used New-PSSession and Invoke-Command to run my Arduino CLI commands as a local Windows user. I stored that user's password in Github to avoid exposing it unnecessarily:

- name: Run Arduino CLI Installation scripts
    shell: powershell
    run: |
        $password = "${{ secrets.PASSWORD }}" | ConvertTo-SecureString -AsPlainText -Force
        $cred = New-Object System.Management.Automation.PSCredential -ArgumentList "MyDomain\MyUser",$password
        $MySession = New-PSSession -Credential $cred
        Invoke-Command -Session $MySession -ScriptBlock { 
            whoami 
            arduino-cli core update-index --config-file arduino-cli.yaml
            arduino-cli lib install ArduinoJson@7.1.0 
            arduino-cli core install esp32:esp32@2.0.5
            cd C:\actions-runner\_work\MyDir
            arduino-cli compile -b esp32:esp32:esp32s2 --output-dir .\bin
        }

I like the idea of trying a Linux runner if I ever get a second build server. Currently, I'm using a Windows runner since my build machine is shared with several .NET projects, and I tend to have more luck building those with a Windows machine.