hashicorp / packer-plugin-virtualbox

Packer plugin for VritualBox Builder
https://www.packer.io/docs/builders/virtualbox
Mozilla Public License 2.0
22 stars 37 forks source link

Environment variable LOGNAME or USER does not correspond to effective user id #130

Open tompscanlan opened 4 months ago

tompscanlan commented 4 months ago

Overview of the Issue

Running packer on a host indirectly. I'm seeing a warning that looks like it is causing a parsing error. when doing a VBoxManage --version.

This is the error:

Error reading version for guest additions download: No version found: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id. 7.0.16r162802

Reproduction Steps

I'm only able reproduce using this indirect call to packer through another tool. Error seems to be here: https://github.com/hashicorp/packer-plugin-virtualbox/blob/54c5a2462f860ba5f18d5817b83f51f8eed2f962/builder/virtualbox/common/driver_4_2.go#L321 when a string is prepended to the version.

Plugin and Packer version

Packer v1.10.2

Simplified Packer Buildfile

If the file is longer than a few dozen lines, please include the URL to the gist of the log or use the Github detailed format instead of posting it directly in the issue.

Operating system and Environment details

Happens on Ubuntu and Rocky Linux.

Log Fragments and crash.log files

virtualbox-iso.vm: output will be in this color.
2024/04/29 20:44:09 packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64 plugin: 2024/04/29 20:44:09 VBoxManage path: /usr/bin/VBoxManage
2024/04/29 20:44:09 packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64 plugin: 2024/04/29 20:44:09 VBoxManage --version output: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.
2024/04/29 20:44:09 packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64 plugin: 7.0.16r162802
2024/04/29 20:44:09 [INFO] (telemetry) ending virtualbox-iso.vm
7.0.16r162802
==> Wait completed after 29 milliseconds 413 microseconds
2024/04/29 20:44:09 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2024/04/29 20:44:09 machine readable: virtualbox-iso.vm,error []string{"Error reading version for guest additions download: No version found: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.\n7.0.16r162802"}
7.0.16r162802
==> Builds finished but no artifacts were created.
2024/04/29 20:44:09 [INFO] (telemetry) Finalizing.
Build 'virtualbox-iso.vm' errored after 29 milliseconds 337 microseconds: Error reading version for guest additions download: No version found: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.
7.0.16r162802
==> Wait completed after 29 milliseconds 413 microseconds
==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso.vm: Error reading version for guest additions download: No version found: WARNING: Environment variable LOGNAME or USER does not correspond to effective user id.
7.0.16r162802
==> Builds finished but no artifacts were created.
2024/04/29 20:44:10 waiting for all plugin processes to complete...
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
2024/04/29 20:44:10 /tmp/runner-3846468805/.config/packer/plugins/github.com/hashicorp/virtualbox/packer-plugin-virtualbox_v1.0.5_x5.0_linux_amd64: plugin process exited
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
2024/04/29 20:44:10 /usr/local/bin/packer: plugin process exited
tompscanlan commented 4 months ago

Opened ticket upstream, but we could be defensive with a slightly tighter regex.

https://www.virtualbox.org//ticket/22060#ticket

nywilken commented 1 month ago

Hi there @tompscanlan this is not a bug in the plugin, as the returned version from VBoxManage --version is returning "Environment variable LOGNAME or USER does not correspond to effective user id\n7.0.16r162802" which is indeed not a validated version. The VBoxManage command is returning this warning because the invocation of Packer is executed by a user whose name does not match the logged-in user $LOGNAME. Can you shed some light on where you are invoking Packer and how?

Are you invoking the script via a crontab?

If you are invoking Packer from a crontab, specify a username or set the user to $LOGNAME via env USER=$LOGNAME in the crontab entry.

tompscanlan commented 1 month ago

I forget details now, but invocation was not via crontab, but was indirect like Makefile -> scriptA.sh -> scriptB.sh which may have switched users.

The real issue is upstream I believe, My ask here is to improve the error message. I dug for a bit and could have saved time with a better error. If it doesn't make sense to change, then no worries, just close.