Skip to content

Fix Makefile Mac compatibility issues#221

Open
DovnarAlexander wants to merge 1 commit intoViktorUJ:masterfrom
DovnarAlexander:feature/make-file-macos-compatible
Open

Fix Makefile Mac compatibility issues#221
DovnarAlexander wants to merge 1 commit intoViktorUJ:masterfrom
DovnarAlexander:feature/make-file-macos-compatible

Conversation

@DovnarAlexander
Copy link

The terragrint_run function had several shell syntax issues that prevented it from working correctly on macOS:

  1. Shell variable scoping problem:

    • Each line with @ was executed in separate shell contexts
    • Variables like run_type and commnand weren't persisting between commands
    • Fixed by combining all commands into a single shell command using line continuations () and semicolons
  2. Variable expansion issues:

    • Changed ${VAR} to $(VAR) for proper Make variable expansion
    • Fixed shell variable references to use proper $$var syntax
  3. Command execution problems:

    • mkdir syntax: changed from 'mkdir $$dir -p' to 'mkdir -p "$$dir"'
    • Added proper quoting around paths to handle spaces
    • Fixed cp command path construction
  4. Case statement syntax:

    • Added proper line continuations to case statements
    • Ensured all commands are part of the same shell context

These changes ensure the Makefile works identically on both Linux and macOS while maintaining the same functionality. The terragrint_run function now properly sets variables, creates directories, copies files, and executes terragrunt commands as intended.

Tested with: USER_ID=test ENV_ID=01 TASK=01 make run_cka_mock on both mac & linux (container)

The terragrint_run function had several shell syntax issues that prevented
it from working correctly on macOS:

1. Shell variable scoping problem:
   - Each line with @ was executed in separate shell contexts
   - Variables like run_type and commnand weren't persisting between commands
   - Fixed by combining all commands into a single shell command using
     line continuations (\) and semicolons

2. Variable expansion issues:
   - Changed ${VAR} to $(VAR) for proper Make variable expansion
   - Fixed shell variable references to use proper $$var syntax

3. Command execution problems:
   - mkdir syntax: changed from 'mkdir $$dir -p' to 'mkdir -p "$$dir"'
   - Added proper quoting around paths to handle spaces
   - Fixed cp command path construction

4. Case statement syntax:
   - Added proper line continuations to case statements
   - Ensured all commands are part of the same shell context

These changes ensure the Makefile works identically on both Linux and macOS
while maintaining the same functionality. The terragrint_run function now
properly sets variables, creates directories, copies files, and executes
terragrunt commands as intended.

Tested with: USER_ID=test ENV_ID=01 TASK=01 make run_ckad_mock
@VitaliAndrushkevich
Copy link
Collaborator

VitaliAndrushkevich commented Oct 11, 2025

Hi @DovnarAlexander !
Which version of make did you use initially to execute it?
If I remember correctly, by default on mac there was version 3 of GNU Make and we have added a specific requirement for GNU Make.

GNU Make >= 4.2.1

On my mac with 26.0.1 default GNU Make version is 3.8.1 and it can be updated for example using homebrew.

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