balajiprasadb
balajiprasadb

Reputation: 395

AWS Codedeploy fails in DownloadBundle event saying No such file or directory

I'm using AWS Codedeploy to deploy my code from GitHub to AWS EC2 instance(Windows 2008 server). Deployment fails in DownloadBundle event

Error stack in logs of AWS :

No such file or directory - C:\ProgramData/Amazon/CodeDeploy/4fbb84fd-caa5-4d1a-9894-16b25abcea76/d-QUPXMDBCF/deployment-archive-temp/My-Application-163e9d3343be82038fe2e5c58a9fcae86683d4ea/src/main/java/com/myapp/dewa/customexceptions/EventNotPublishedException.java

The problem here might be with the file path limit of windows.

UPDATE: AWS CodeDeploy Support team has confirmed that this is a limitation from their side. More than half of the file path is being used by CodeDeploy because of which limit is being exceeded

Upvotes: 6

Views: 3746

Answers (3)

Nick Rubino
Nick Rubino

Reputation: 1045

If you are using Windows 2016, setting the value to 1 for the following registry entry will fix the issue with long paths.

HKLM:SYSTEM\CurrentControlSet\Control\FileSystem

Referencing iskandar's post this can be done through a powershell script if you wish to automate it in something like a startup script.

# @see https://github.com/aws/aws-codedeploy-agent/issues/46
# @see https://learn.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#paths
Write-Verbose "----> Enabling Long Path Support"
$RegistryPath = "HKLM:SYSTEM\CurrentControlSet\Control\FileSystem"
$Name = "LongPathsEnabled"
New-ItemProperty -Path $RegistryPath -Name $Name -Value 1 -PropertyType DWORD -Force | Out-Null
# You'll want to reboot to make sure; this is Windows we're working with.
Restart-Computer

You can also use the GUI method outlined in this post.

Note - either method will definitely require a restart for the setting to take affect

Upvotes: 1

Neil Fahardoh
Neil Fahardoh

Reputation: 31

While not a complete solution, I've experienced the same problem and we were able to remove the preceding 'ProgramData\Amazon\CodeDeploy' to save 29 characters if you can stand the mess in your root folder.

To do this we modified the conf.yml file located in c:\programdata\amazon\codedeploy\

I changed ... root_dir: 'Amazon\CodeDeploy' ... to ... root_dir: 'C:\'

Upvotes: 3

Rafiq
Rafiq

Reputation: 1642

Have you replaced some strings from the file_path and/or file_name?

This error you get when the total length of the file_path is beyond 260 characters. This length includes one null character at the end for termination. Your total length is 239+1 = 240.

For reference, please see this article: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath

If you check the path in the destination, you should not see the file because it was not copied but it is in your revision zip file.

In my case, the total length was 266. It may not be possible to shorten the strings of the actual file path in the revision since lots of them are created by the developer tools. Amazon is investing at their end now to see how to overcome this.

You can test and confirm by doing the following:

  1. Run the following command in the command prompt to create the deployment archive folder: mkdir "c:\ProgramDat0/Amazon/CodeDeploy/4fbb84fd-caa5-4d1a-9894-16b25abcea76/d-QUPXMDBCF/deployment-archive-temp"

  2. Simply try to extract your revision zip file directly under 'deployment-archive-temp' folder. You should received the following error for file crossing the maximum path length of 260: 'Error 0x80010135: Path too long'

Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath

I hope this helps.

Upvotes: 5

Related Questions