Quick Tips: AWS CodeDeploy “couldn’t find HOME environment — expanding `~'” fix.

If you ever run into the above error it can be a pain to debug as the message is not very clear. What it the message is _trying_ to say is ‘Unable to find source or destination directory or file. Please check your configuration and try again’. But I do not write error messages so here are the resources and configurations to look into if you experience the same error.

  • First, check appspec.yml, specifically the ‘files’ section. ‘source’ and ‘destination’ resources must exist and the matching pattern must be correct.
...
files:
- source: target/*.java
destination: ~/javaapp/
...
  • Check the CodeBuild buildspec.yml configuration file next. Look in the ‘artifacts’ section and double check the resources and matching patterns. Ensure appspec.yml is included for use with CodeDeploy.
...
artifacts:
type: zip
files:
- 'appspec.yml'
- 'scripts/*'
- 'target/app.java'
...
  • If both the appspec.yml and buildspec.yml look good, log into the machine and look under the /opt/ directory. Follow the path to the bundle.gz file. Dig around that directory and ensure all the resources needed to deploy the application are present.
  • Finally, if appspec, buildspec, and the resources are present in the CodeDeploy directory; check the target location the application files are moved (copied) to. Especially is you have any ./scripts/* that start/configure/restart/stop the application. These scripts are outside what CodeDeploy knows about and cane easily FUBAR a deployment.

I know I spent way to long trying to figure out why my java program was not working when the buildspec was outputting a *.java but appspec wanted a *.jar. It happens. If this helped you in any way please drop me a comment below and let me know.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.