aws-samples / aws-samples/sample-ai-possibilities

MacOS: cli 'deploy_all.sh' failing with directory not found

Open Beginner friendly
#151 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
40
Forks
36
Avg merge
5h 26m
Merged PRs (30d)
1

Description

On MacOS running
`sample-ai-possibilities/agentic-football-sample-agents/ai-team-strands-gateway/deploy-all.sh` or
`sample-ai-possibilities/agentic-football-sample-agents/ai-team-strands-memory/deploy-all.sh`
(and other copies)
fails, as it uses the TMPDIR system variable to create a folder
(line 115:
`TMPDIR=$(mktemp -d)`
)
However, unlike on Linux (where it points to /var/tmp/) on MacOS it points to a SIP protected folder, thus disallowing creation & deletion:
```
export TMPDIR=/private/var/folders/bw/869b6hcd761btl8dc_3zkh4c0000gn/T
sample-ai-possibilities/agentic-football-sample-agents/ai-team-strands-gateway on  main [?] via 🐍 v3.10.21 (.venv) on 🅰 (us-east-1)
› ./deploy-all.sh
AI Team (Gateway) — Deploy Agents
Checking prerequisites...
agentcore: OK
aws: OK
AWS Account: ***********
AWS Region: us-east-1
Step 1: Lambda IAM Role
Role ARN: arn:aws:iam::********:role/afwc-gateway-tool-lambda-role

Step 2: Deploy Lambda Functions
Updating: afwc-gateway-tool-calculate-pass-options
mktemp: failed to create directory via template ‘/private/var/folders/bw/869b6hcd761btl8dc_3zkh4c0000gn/T/tmp.jVFkwEpAtq/tmp.XXXXXXXXXX’: No such file or directory
```

The solution is to rename TMPDIR to any other name, like WORK_DIR.
So change (line 115+)
```
TMPDIR=$(mktemp -d)
cp "$TOOL_FILE" "$TMPDIR/lambda_function.py"
sed -i'' -e 's/^def handler(/def lambda_handler(/' "$TMPDIR/lambda_function.py"
(cd "$TMPDIR" && zip -q function.zip lambda_function.py)
```
to
```
WORK_DIR=$(mktemp -d)
cp "$TOOL_FILE" "$WORK_DIR/lambda_function.py"
sed -i'' -e 's/^def handler(/def lambda_handler(/' "$WORK_DIR/lambda_function.py"
(cd "$WORK_DIR" && zip -q function.zip lambda_function.py)
```
line 127 to
```
--zip-file "fileb://$WORK_DIR/function.zip" \
```
and line 134 to
```
--zip-file "fileb://$WORK_DIR/function.zip" \
```

Contributor guide

Open the contributing guide

Research direction

Start with the deploy-all.sh copies under ai-team-strands-gateway and ai-team-strands-memory, focusing on the temporary-directory handling around line 115 and the zip-file arguments around lines 127 and 134. Reproduce the failure on macOS, update the affected copies consistently, and rerun deployment to confirm the directory is created and the Lambda package uploads successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, shell
Domain
cloud, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.