Skip to content

fix: resolve unbound variable error for tmp_phar and tmp_checksum under set -u#43

Merged
mrrobot47 merged 4 commits into
masterfrom
fix/unbound-tmp-phar-variable
Mar 27, 2026
Merged

fix: resolve unbound variable error for tmp_phar and tmp_checksum under set -u#43
mrrobot47 merged 4 commits into
masterfrom
fix/unbound-tmp-phar-variable

Conversation

@mrrobot47

@mrrobot47 mrrobot47 commented Mar 27, 2026

Copy link
Copy Markdown
Member

Problem

When the installer runs in a strict shell environment with set -u (treat unbound variables as errors), the Ansible play failed at helper-functions:313 with:

/tmp/ee-installer.wYvtE4/helper-functions: line 313: tmp_phar: unbound variable

Root cause

The two-line pattern used to declare and assign temp file variables:

local tmp_phar
tmp_phar="$(mktemp /tmp/easyengine.phar.XXXXXX)"

creates a narrow window where tmp_phar is declared (via local) but still unset. If the RETURN trap or any early exit fires in that gap, bash sees an unbound variable and aborts with the error above.

…er set -u

When the installer runs under a strict shell environment with 'set -u'
(treat unbound variables as errors), the two-line pattern of:

  local tmp_phar
  tmp_phar="$(mktemp ...)"

causes a 'tmp_phar: unbound variable' error if the RETURN trap or any
early exit fires between the 'local' declaration and the assignment.
This manifested as a failed Ansible play at helper-functions line 313.

Fix: combine the declaration and mktemp assignment onto a single line
using the semicolon idiom:

  local tmp_phar; tmp_phar="$(mktemp ...)"

This ensures the variable is always bound the moment it is declared,
eliminating the race window. The inline form 'local var=$(cmd)' is
intentionally avoided because bash's 'local' built-in masks the exit
code of the subshell, making mktemp failures invisible.

Applied the same fix to tmp_checksum for consistency.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the EasyEngine installer helper script to avoid “unbound variable” failures when run under strict bash settings (set -u), specifically around temp file variables used during the phar download/install flow.

Changes:

  • Updates temp file variable initialization for tmp_phar and tmp_checksum in download_and_install_easyengine().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread functions Outdated
- Quote $LOG_FILE in touch call to be safe against paths with spaces
- Separate 'export EE_LINUX_DISTRO=$(...)' into assignment then export;
  the combined form masks the exit code of the subshell under set -e
- Fix long-standing typo: check_depdendencies -> check_dependencies
  in both the function definition (functions) and the call site (setup.sh)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread functions
Extends the rename from check_depdendencies -> check_dependencies to
the migration scripts that were missed in the previous commit:

- migration/migrate.sh: call site at line 100
- migration/remote-migrate: function definition check_depdendencies_remote
  renamed to check_dependencies_remote, and its call site at line 81

No remaining occurrences of the misspelled name exist in the codebase.
@mrrobot47 mrrobot47 merged commit dab184f into master Mar 27, 2026
1 check passed
@mrrobot47 mrrobot47 deleted the fix/unbound-tmp-phar-variable branch March 27, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants