Local build not working on Mac with -b option
I am running local build .sh file on Mac to run cobebuild agent locally, but seeing following error.
Command:
./codebuild_build.sh -i aws/codebuild/python:3.6.5 -a /Users/sshvans/Documents/artifacts -s /Users/sshvans/Documents/test -b /Users/sshvans/Documents/test/assets/buildspec.yml
Output: `Build Command:
docker run -it -v /var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/python:3.6.5" -e "ARTIFACTS=/Users/sshvans/Documents/artifacts" -e "SOURCE=/Users/sshvans/Documents/test" -e "BUILDSPEC=/Users/sshvans/Documents/test/assets/buildspec.yml" amazon/aws-codebuild-local:latest
Removing agentresources_build_1 ... done Removing agentresources_agent_1 ... done Removing network agentresources_default Removing volume agentresources_user_volume Removing volume agentresources_source_volume Creating network "agentresources_default" with the default driver Creating volume "agentresources_user_volume" with local driver Creating volume "agentresources_source_volume" with local driver Creating agentresources_agent_1 ... Creating agentresources_agent_1 ... done Creating agentresources_build_1 ... Creating agentresources_build_1 ... done Attaching to agentresources_agent_1, agentresources_build_1 agent_1 | [Container] 2018/08/16 23:23:09 Waiting for agent ping agent_1 | [Container] 2018/08/16 23:23:09 Waiting for DOWNLOAD_SOURCE agent_1 | [Container] 2018/08/16 23:23:10 Phase is DOWNLOAD_SOURCE agent_1 | [Container] 2018/08/16 23:23:10 CODEBUILD_SRC_DIR=/codebuild/output/src954031307/src agent_1 | [Container] 2018/08/16 23:23:10 Phase complete: DOWNLOAD_SOURCE Success: false agent_1 | [Container] 2018/08/16 23:23:10 Phase context status code: YAML_FILE_ERROR Message: stat /Users/sshvans/Documents/test/assets/buildspec.yml: no such file or directory agent_1 | [Container] 2018/08/16 23:23:10 Runtime error (*os.PathError: stat /Users/sshvans/Documents/test/assets/buildspec.yml: no such file or directory)`
At first it seems like the buildspec.yml file doesn't exist at the given location, but I have confirmed and this file do exist. When I remove the the -b option, the command runs successfully. See below.
Command:
./codebuild_build.sh -i aws/codebuild/python:3.6.5 -a /Users/sshvans/Documents/artifacts -s /Users/sshvans/Documents/test
Output: ` Build Command:
docker run -it -v /var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/python:3.6.5" -e "ARTIFACTS=/Users/sshvans/Documents/Work/artifacts" -e "SOURCE=/Users/sshvans/Documents/test" amazon/aws-codebuild-local:latest
Removing agentresources_build_1 ... done Removing agentresources_agent_1 ... done Removing network agentresources_default Removing volume agentresources_user_volume Removing volume agentresources_source_volume Creating network "agentresources_default" with the default driver Creating volume "agentresources_user_volume" with local driver Creating volume "agentresources_source_volume" with local driver Creating agentresources_agent_1 ... Creating agentresources_agent_1 ... done Creating agentresources_build_1 ... Creating agentresources_build_1 ... done Attaching to agentresources_agent_1, agentresources_build_1 agent_1 | [Container] 2018/08/16 23:30:56 Waiting for agent ping agent_1 | [Container] 2018/08/16 23:30:56 Waiting for DOWNLOAD_SOURCE agent_1 | [Container] 2018/08/16 23:30:57 Phase is DOWNLOAD_SOURCE agent_1 | [Container] 2018/08/16 23:30:57 CODEBUILD_SRC_DIR=/codebuild/output/src885802506/src agent_1 | [Container] 2018/08/16 23:30:57 YAML location is /codebuild/output/src885802506/src/buildspec.yml agent_1 | [Container] 2018/08/16 23:30:57 Processing environment variables agent_1 | [Container] 2018/08/16 23:30:57 Moving to directory /codebuild/output/src885802506/src agent_1 | [Container] 2018/08/16 23:30:57 Registering with agent agent_1 | [Container] 2018/08/16 23:30:57 Phases found in YAML: 3 agent_1 | [Container] 2018/08/16 23:30:57 INSTALL: 4 commands agent_1 | [Container] 2018/08/16 23:30:57 PRE_BUILD: 14 commands agent_1 | [Container] 2018/08/16 23:30:57 BUILD: 4 commands agent_1 | [Container] 2018/08/16 23:30:57 Phase complete: DOWNLOAD_SOURCE Success: true agent_1 | [Container] 2018/08/16 23:30:57 Phase context status code: Message: agent_1 | [Container] 2018/08/16 23:30:57 Entering phase INSTALL agent_1 | [Container] 2018/08/16 23:30:57 Running command echo Entered the install phase... agent_1 | Entered the install phase... agent_1 | agent_1 | [Container] 2018/08/16 23:30:57 Running command apt-get update -y agent_1 | Get:1 http://ppa.launchpad.net trusty InRelease [15.4 kB] agent_1 | Ign http://archive.ubuntu.com trusty InRelease agent_1 | Get:2 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB] agent_1 | Get:3 http://archive.ubuntu.com trusty-security InRelease [65.9 kB] agent_1 | Get:4 http://archive.ubuntu.com trusty Release.gpg [933 B] agent_1 | Get:5 http://archive.ubuntu.com trusty Release [58.5 kB] agent_1 | Get:6 http://ppa.launchpad.net trusty/main amd64 Packages [3482 B] agent_1 | Get:7 http://archive.ubuntu.com trusty-updates/main Sources [519 kB] . . `
Hi,
The -b option takes relative path as input. In this case, since your buildspec is in assets/buildspec.yml, you can specify -b assets/buildspec.yml to make it work.
If you don't specify anything, the local agent will look for buildspec.yml in root dir of your source.
Thanks,
Please re-investigate this error, I still see this issue today using the latest version of codebuild_build.sh script, screenshot:

@ntt2k Did you find any solution for this already? I'm experiencing same issues here.. have you tried putting the buildspec.yml temporarily in the root? Does it work then?
@ntt2k if I run codebuild local with "-c default" it gives the same error. are you trying to use the default profile there? if I run it with "-c -p default" it works