Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes root-directory name of YAML_FILE - path to uppercase automatically, which leads to YAML_FILE_ERROR: no such file or directory #470

Open
AndreasLuckert opened this issue Jul 5, 2021 · 5 comments
Labels
CodeBuild-local Tag to track issues and PRs for CodeBuild local Docker image Windows

Comments

@AndreasLuckert
Copy link

I run the AWS-CodeBuild locally with the following command in the root-directory of the related project "projectname":

username@hd1pcms0347 MINGW64 ~/Projects/projectname (dev-platform-al)
$ ../aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:5.0 -a artifacts-output-projectname -s . -b src/build/buildspec.tests.pre-deploy.yml -c /c/Users/username/.aws/config

The output Build Command in the CLI is:

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:5.0" -e "ARTIFACTS=//Artifacts-output-projectname" -e "SOURCE=//C/Users/username/Projects/projectname/." -e "BUILDSPEC=//Src/build/buildspec.tests.pre-deploy.yml" -e "AWS_CONFIGURATION=//C/Users/username/.aws" -e "INITIATOR=username" amazon/aws-codebuild-local:latest

Removing agent-resources_build_1 ... done
Removing agent-resources_agent_1 ... done
Removing network agent-resources_default
Removing volume agent-resources_source_volume
Removing volume agent-resources_user_volume
Creating network "agent-resources_default" with the default driver
Creating volume "agent-resources_source_volume" with local driver
Creating volume "agent-resources_user_volume" with local driver
Creating agent-resources_agent_1 ... done
Creating agent-resources_build_1 ... done
Attaching to agent-resources_agent_1, agent-resources_build_1
agent_1  | [Container] 2021/07/05 11:58:43 Waiting for agent ping
agent_1  | [Container] 2021/07/05 11:58:45 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/05 11:58:46 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/05 11:58:46 CODEBUILD_SRC_DIR=/codebuild/output/src055514407/src
agent_1  | [Container] 2021/07/05 11:58:46 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2021/07/05 11:58:46 Phase context status code: YAML_FILE_ERROR Message: stat /Src/build/buildspec.tests.pre-deploy.yml: no such file or directory
agent_1  | [Container] 2021/07/05 11:58:46 Runtime error (*clienterr.PhaseContextError: stat /Src/build/buildspec.tests.pre-deploy.yml: no such file or directory)
agent-resources_agent_1 exited with code 0
Aborting on container exit...

Error: /Src/build/buildspec.tests.pre-deploy.yml: no such file or directory

The actual root-directory starts with a lower case like so:
src\build\buildspec.tests.pre-deploy.yml

Now this begs the question why the software would change the first letter from lowercase to uppercase?

Next, what does the following state stand for:
DOWNLOAD_SOURCE State: FAILED

Is it related to the previous ill-renaming of the root-directory /scr/?

@josephvusich
Copy link
Contributor

josephvusich commented Jul 8, 2021

It looks like you're using Windows, which is not fully supported by CodeBuild Local.

Looking at the logs provided, it seems that the relative file paths are being misinterpreted as UNC absolute paths. Specifying a leading ./ may help, as in ./src. In any case, this should be addressed by #328.

@AndreasLuckert
Copy link
Author

Yes, I'm on Windows 10 indeed.

Just tried it with -b ./src/... instead of -b src/.., see the entire command here:
../aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:5.0 -a artifacts-output-projectname -s . -b ./src/build/buildspec.tests.pre-deploy.yml -c /c/Users/andreas.luckert/.aws/config

The entire output till failure was:

Build Command:

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:5.0" -e "ARTIFACTS=//Artifacts-output-projectname" -e "SOURCE=//C/Users/andreas.luckert/Projects/proj/." -e "BUILDSPEC=//C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml" -e "AWS_CONFIGURATION=//C/Users/andreas.luckert/.aws" -e "INITIATOR=andreas.luckert" amazon/aws-codebuild-local:latest

Removing agent-resources_build_1 ... done
Removing agent-resources_agent_1 ... done
Removing network agent-resources_default
Removing volume agent-resources_source_volume
Removing volume agent-resources_user_volume
Creating network "agent-resources_default" with the default driver
Creating volume "agent-resources_source_volume" with local driver
Creating volume "agent-resources_user_volume" with local driver
Creating agent-resources_agent_1 ... done
Creating agent-resources_build_1 ... done

Attaching to agent-resources_agent_1, agent-resources_build_1
agent_1  | [Container] 2021/07/09 07:22:04 Waiting for agent ping
agent_1  | [Container] 2021/07/09 07:22:06 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/09 07:22:07 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/09 07:22:07 CODEBUILD_SRC_DIR=/codebuild/output/src243879863/src
agent_1  | [Container] 2021/07/09 07:22:07 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2021/07/09 07:22:07 Phase context status code: YAML_FILE_ERROR Message: stat 

/C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory
agent_1  | [Container] 2021/07/09 07:22:07 Runtime error (*clienterr.PhaseContextError: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory)

agent-resources_build_1 exited with code 11
Aborting on container exit...

This time, the program prepended the full path, but again made the first letter capital (/C/.. instead of /c/...).

@josephvusich
Copy link
Contributor

/C/Users looks like MSYS path translation from the shell/terminal. You may be able to get around this by using absolute paths starting with C:.

@AndreasLuckert
Copy link
Author

AndreasLuckert commented Jul 12, 2021

Following your advice, I replaced -b ./src/build/buildspec.tests.pre-deploy.yml with
"C:\Users\andreas.luckert\Projects\proj\src\build\buildspec.tests.pre-deploy.yml"

to get the final command:
../aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:5.0 -a artifacts-output-projectname -s . -b "C:\Users\andreas.luckert\Projects\proj\src\build\buildspec.tests.pre-deploy.yml" -c /c/Users/andreas.luckert/.aws/config

The output was yet again:

Build Command:

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:5.0" -e "ARTIFACTS=//Artifacts-output-projectname" -e "SOURCE=//C/Users/andreas.luckert/Projects/proj/." -e "BUILDSPEC=//C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml" -e "AWS_CONFIGURATION=//C/Users/andreas.luckert/.aws" -e "INITIATOR=andreas.luckert" amazon/aws-codebuild-local:latest

Removing agent-resources_build_1 ... done
Removing agent-resources_agent_1 ... done
Removing network agent-resources_default
Removing volume agent-resources_source_volume
Removing volume agent-resources_user_volume
Creating network "agent-resources_default" with the default driver
Creating volume "agent-resources_source_volume" with local driver
Creating volume "agent-resources_user_volume" with local driver
Creating agent-resources_agent_1 ... done
Creating agent-resources_build_1 ... done
Attaching to agent-resources_agent_1, agent-resources_build_1
agent_1  | [Container] 2021/07/12 07:54:48 Waiting for agent ping
agent_1  | [Container] 2021/07/12 07:54:50 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/12 07:54:50 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/12 07:54:50 CODEBUILD_SRC_DIR=/codebuild/output/src154752762/src
agent_1  | [Container] 2021/07/12 07:54:50 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2021/07/12 07:54:50 Phase context status code: YAML_FILE_ERROR Message: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory
agent_1  | [Container] 2021/07/12 07:54:50 Runtime error (*clienterr.PhaseContextError: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory)
agent-resources_build_1 exited with code 11
Aborting on container exit...

Then, for the sake of completeness, I replaced also -c /c/Users/andreas.luckert/.aws/config with
"C:\Users\andreas.luckert\.aws\config"

to obtain the final command:
../aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:5.0 -a artifacts-output-projectname -s . -b "C:\Users\andreas.luckert\Projects\proj\src\build\buildspec.tests.pre-deploy.yml" -c "C:\Users\andreas.luckert\.aws\config"

Regarding the output, it did not have a notable effect:

Build Command:

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:5.0" -e "ARTIFACTS=//Artifacts-output-projectname" -e "SOURCE=//C/Users/andreas.luckert/Projects/proj/." -e "BUILDSPEC=//C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml" -e "AWS_CONFIGURATION=//C/Users/andreas.luckert/.aws" -e "INITIATOR=andreas.luckert" amazon/aws-codebuild-local:latest

Removing agent-resources_build_1 ... done
Removing agent-resources_agent_1 ... done
Removing network agent-resources_default
Removing volume agent-resources_source_volume
Removing volume agent-resources_user_volume
Creating network "agent-resources_default" with the default driver
Creating volume "agent-resources_source_volume" with local driver
Creating volume "agent-resources_user_volume" with local driver
Creating agent-resources_agent_1 ... done
Creating agent-resources_build_1 ... done
Attaching to agent-resources_agent_1, agent-resources_build_1
agent_1  | [Container] 2021/07/12 07:55:49 Waiting for agent ping
agent_1  | [Container] 2021/07/12 07:55:51 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/12 07:55:51 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/12 07:55:51 CODEBUILD_SRC_DIR=/codebuild/output/src572911371/src
agent_1  | [Container] 2021/07/12 07:55:51 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2021/07/12 07:55:51 Phase context status code: YAML_FILE_ERROR Message: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory
agent_1  | [Container] 2021/07/12 07:55:51 Runtime error (*clienterr.PhaseContextError: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory)   
agent-resources_build_1 exited with code 11
Aborting on container exit...

NOTE on double-quotes around the paths containing the Windows-separator "":

This is mandatory since without quotes e.g. the buildspec.yml - file would be interpreted like so:
/CUsersandreas.luckertProjectsprojsrcbuildbuildspec.tests.pre-deploy.yml

@subinataws subinataws added CodeBuild-local Tag to track issues and PRs for CodeBuild local Docker image Windows labels Jul 2, 2022
@devt
Copy link

devt commented Apr 6, 2023

Not positive, but maybe this issue is addressed by pending PR #619 or my version

See comment #328 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CodeBuild-local Tag to track issues and PRs for CodeBuild local Docker image Windows
Projects
None yet
Development

No branches or pull requests

4 participants