Skip to content

Binary verification fails with misleading error when file command is not available #11

@chrismo

Description

@chrismo

The plugin's binary verification step fails silently when the file command is not installed on the system, producing a misleading
error message.

Environment:

  • Docker container: public.ecr.aws/lambda/provided:latest-arm64 (Amazon Linux 2023)
  • asdf-superdb plugin: latest
  • SuperDB version: 0.51016

Steps to Reproduce:

  1. Use a minimal system without file command installed (e.g., Amazon Linux 2023 base image)
  2. Install asdf and the superdb plugin
  3. Run asdf install superdb 0.51016

Actual Behavior:

  • verify_binary /root/.asdf/downloads/superdb/0.51016/superdb-0.51016
  • [[ '' =~ (executable|ELF|Mach-O) ]]
  • echo 'Downloaded file is not a valid binary executable'
  • return 1

The error message suggests the binary itself is invalid, when the actual issue is that the file command is missing.

Expected Behavior:
Either:

  1. Clear error indicating file command is required but not found
  2. Documentation stating file is a required dependency

Verification:
When I installed the same binary on a system with file available (Ubuntu 20), verification succeeds:
$ file superdb-0.51016
superdb-0.51016: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked,
BuildID[sha1]=9406f764f92979fc8c6672672a49cf98b0d74416, stripped

Suggested Fix:
Add a check in the verify_binary function:

verify_binary() {
local binary_path="$1"

if ! command -v file >/dev/null 2>&1; then
  echo "ERROR: 'file' command not found. Please install file utilities (e.g., 'dnf install file' or 'apt-get install file')"
  return 1
fi

# ... existing validation logic

}

Workaround:
Install the file package before running asdf install:
RUN dnf install -y file # or apt-get install -y file

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions