Migrating configuration fails with PathTooLongException

When I try to migrate the configuration from one machine to a different machine from powershell fails with the exceptionPathTooLongException (stacktrace below). Is there a way around this problem?

For more background on what we’re trying to do (in case you can think of alternative solutions) we are trying to figure out a way to have a test server and a production server on different networks. So the configuration is done on the test server and then when we’re done we migrate those settings to our production service (our idea was to do it via SVN by checking in the json-files) and run a script that imports the settings. For obvious reasons, we want to maintain different deploy histories on both servers. Right now, though, we’re stranded by the fact that we can’t even import the settings from the json-files.

Full exception and stacktrace:

System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
at System.IO.PathHelper.GetFullPathName()
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamReader…ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)
at Octopus.Migrator.ImportProcess.ImportController.ImportScript(ImportContext context, String scriptFile) in Y:\work\refs\tags\3.3.8\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 471
at Octopus.Migrator.ImportProcess.ImportController.ImportScripts(ImportContext context) in Y:\work\refs\tags\3.3.8\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 460
at Octopus.Migrator.ImportProcess.ImportController.ExecuteWithTimer(ImportContext ctx, String name, Action1 work) in Y:\work\refs\tags\3.3.8\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 140 at Octopus.Migrator.ImportProcess.ImportController.ImportDocuments(IImportedDocumentSource backup) in Y:\work\refs\tags\3.3.8\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 103 at Octopus.Migrator.ImportProcess.ImportController.Import(IImportedDocumentSource backup) in Y:\work\refs\tags\3.3.8\source\Octopus.Migrator\ImportProcess\ImportController.cs:line 61 at Octopus.Migrator.Commands.ImportFilesCommand.Start() in Y:\work\refs\tags\3.3.8\source\Octopus.Migrator\Commands\ImportFilesCommand.cs:line 91 at Octopus.Shared.Startup.AbstractCommand.Octopus.Shared.Startup.ICommand.Start(String[] commandLineArguments, ICommandRuntime commandRuntime, OptionSet commonOptions) in Y:\work\refs\tags\3.3.8\source\Octopus.Shared\Startup\AbstractCommand.cs:line 58 at Octopus.Shared.Startup.ConsoleHost.Run(Action1 start, Action shutdown) in Y:\work\refs\tags\3.3.8\source\Octopus.Shared\Startup\ConsoleHost.cs:line 72
at Octopus.Shared.Startup.OctopusProgram.Run() in Y:\work\refs\tags\3.3.8\source\Octopus.Shared\Startup\OctopusProgram.cs:line 87


Thanks for getting in touch! Sorry for the troubles. The migrator stores the export as folders using your names as the folder name and file name. It is very possible that this combination has reached the max limit for folder names in Windows.
It would really help us to resolve this problem seeing your real example of naming structures to troubleshoot a solution. Your migration logs would be a great start.
I have made this thread private so only our staff can see the files. Or you can email it to support@octopus.com.

Hopefully this will give us an idea to resolve it.

Thanks for the reply. It gave me the idea to try and get around the problem by moving the checkout repository (as I said, we want to use VPN) from the documents folder to directly under C - and this worked!

I noticed that some files was named peculiarly - they would be named ‘[ProjectName] - [step name] - [step name again] - script.ps1’. I had one step that’s called ‘Import Web Certificate ([certificate name])’ where the certificate name was somewhat long which resulted in the ps1-file having a file name that was 143 characters long (where 55 characters were redundant). On the server I migrated from we use version 3.2.3 - is this a bug that has been corrected in later versions (because to me it really does look like a bug)?

Also, for the record: IIRC 260 is a .NET limit, not a windows limit. I think I’ve run into that problem when trying to copying files in Powershell but I managed to work around it by using xcopy instead of official microsoft cmdlets (or it was someone else - I’m a little fuzzy on the details).

As a last point, since no private details have been posted I wouldn’t mind if this thread was public, by the way. Hopefully it will help someone else.


Yeah the hyphen is a separator to match it to projects and dependencies so that is why the naming looks really extended.
The migrator produces logs, and we would like to make it more robust for all situations that we can. Seeing the log would help us if you could email it to support at octopus dot com.
It means we can hopefully allow better for customer data.


Sure, the log is attached.

Thanks! I downloaded the file but deleted it from here so we can leave the topic public.