Arduino IDE 2.2.1: Request for administrative privileges on first run

Problem: Request for administrative privileges on first run

OS: Windows 10 fully patched
Installation method: EXE
Installation account: Local System

After looking through various posts on the forum I believe I've managed to create a silent install for mass deployment. Among other things this includes the line

arduino-cli.exe core install arduino:avr --run-post-install

According to DPINST.log this pre-installs the drivers.

However, on first run a user without admin rights is asked to provide administrator credentials in order to install the drivers again.

DPINST.log shows that the pre-installed drivers are detected and no further action is taken.

INFO: Found driver package: 'C:\Users<user>\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\drivers\AdafruitCircuitPlayground.inf'.

INFO: ENTER: DriverPackagePreinstallW
INFO: Driver package is already preinstalled 'c:\users<user>\appdata\local\arduino15\packages\arduino\hardware\avr\1.8.6\drivers\adafruitcircuitplayground.inf'.
SUCCESS:c:\users<user>\appdata\local\arduino15\packages\arduino\hardware\avr\1.8.6\drivers\adafruitcircuitplayground.inf is preinstalled.
INFO: RETURN: DriverPackagePreinstallW (0xB7)

How can we avoid this unnecessary request for elevation?

Regards,
DGL

Hi @dgamst.

Analysis of Problem

On the first run, the IDE checks to see if the arduino:avr platform is installed, if the platform is not installed, it installs it. That installation process includes the driver installation that requires administrator credentials.

If the arduino:avr platform is already installed then the IDE will never attempt a driver installation

So the fact that the IDE is attempting a driver installation indicates that when you run the arduino-cli core install command during your mass deployment, arduino:avr is not being installed to the location where Arduino IDE looks for it.

Solution

So the problem can be solved by doing either one of these two things:

  • Configure your arduino-cli core install command to install arduino:avr to the place Arduino IDE expects it to be.
  • Configure Arduino IDE to look for arduino:avr in the place where the arduino-cli core install command put it.

As you probably already noticed, by default arduino-cli core install installs the platform to this path:

C:\Users\<username>\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\

Arduino IDE also looks for the platform in that path. This leads me to believe the <username> component of the path is different due to the arduino-cli core install command having been ran by a different Windows account than the account used when running Arduino IDE.

I think the best way to solve this might be dependent on the specifics of how the systems you are provisioning are intended to be used. I don't have that information so I can't recommend a specific solution. You are surely more knowledgeable about the subject of system administration than me so I think you will be best able to decide the best solution once you understand the cause of the problem (which I hope I have effectively explained above), and the tools available to solve it, which I will describe below.

Arduino CLI Configuration

arduino-cli core install installs the platform to the packages subfolder of the "Arduino data folder". The path of the data folder used by Arduino CLI can be configured via the directories.data configuration key, which can be set in several ways.

The documentation for the Arduino CLI configuration system is here:

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

Arduino IDE Configuration

Arduino IDE looks for the platform in the packages subfolder of the "Arduino data folder". The path of the data folder used by Arduino IDE can be configured via the directories.data configuration key of a configuration file.

The configuration file is located at this path:

C:\Users\<username>\.arduinoIDE\arduino-cli.yaml

This file can be generated and the data in the file adjusted using the arduino-cli config commands:

https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_config/

arduino-cli.yaml is written in the common YAML language. This means that, in case you find arduino-cli config to not be suitable or convenient for your application, you can also use any of the many general purpose tools available for working with data in this format. I can recommend the excellent yq:

Thank you, that put me on the right track. I'd fixated too much on the drivers.

Taking the data folder into consideration resolved the problem.

Regards,
DGL

You are welcome. I'm glad it is working now.

Regards,
Per

Hi @ptillisch

I have a followup question.

I'm packaging Arduino for use in, among other things, an exam context.

This means that it is important that all the library versions are the same across all computers.

Is there a chance when running commands like

arduino-cli.exe core install arduino:avr --run-post-install
arduino-cli.exe lib install Arduino_BuiltIn --install-in-builtin-dir

that the libraries that are downloaded and installed can change over time?

Like 'Keyboard@1.0.5' getting an update to 'Keyboard@1.0.6'?

Regards,
DGL

This will install whatever is the newest available version of the "Arduino AVR Boards" platform. If you want to pin it to a specific version, use the @ syntax on the platform identifier to specify the version you want:

arduino-cli.exe core install arduino:avr@1.8.6 --run-post-install

This will install whatever is the newest available version of the "Arduino_BuiltIn" library. That by itself is not really interesting because the "Arduino_BuiltIn" library is actually only a container for a list of library dependencies that should be installed:

What is more important is that, since constraints are not specified in that list of dependencies, installing the "Arduino_BuiltIn" library also installs the newest available version of each of those dependencies. If you want to pin the versions of those dependencies, you should install them directly using the @ syntax to specify the version:

arduino-cli.exe lib install Ethernet@2.0.2 --install-in-builtin-dir

...and so on (you can list all the libraries to install as arguments in a single command if you like).

If newer versions are available, Arduino IDE will display a notification offering to update them.

You can disable update offers by setting the arduino.checkForUpdates key in the C:\Users\<username>\.arduinoIDE\settings.json file to false.

Thank you very much, @ptillisch

Not the easiest application to package, but the support has been top-notch.

Now for what I believe should be my last question.

On the first run only I get a 'Some indexes could not be updated' message after Arduino has tried to install the libraries and found that they've already been installed.

That would seem to be because I've put the data: (and/or builtin:libraries:) directory where users do not have write access.

Can I safely ignore this message or is write access to the data: (and/or builtin:libraries:) directory required?

Regards,
DGL

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.