Issues
Issues copied to clipboard
Running a script from a package with a long folderpath returns an unrelated error.
Team
- [X] I've assigned a team label to this issue
Severity
Not Blocking
Version
2023.1 (build 686-hotfix 1630)
Latest Version
No response
What happened?
If you have a Nuget package with a powershell script at the location:
content\App\helloworld.ps1
the script will run as expected however running a script from a location with many characters:
content\App\pXpVfbqAQksSSAPXwbTQVtKxOCgxrcdfMtWbqbBFBNpJnYrDKvKVQQNerWfKAcqUovXDmVYcVMCnCpJTHJeUyBpHDEfuYWVokNfH\kBOcwsKGTabUbQjdcACQKtPSaApnzBEWhzjkvKfjQzkxQuAQjysDAkwNnNwRskUFNvDcsWsWMaAefAJjohkyZWAPxtmbNFtwMBtS\AYhbjhguKAbVfVrYegeqQwfCMMhDmJodrJHDKMMrEKAfEVsSSKWKMzGZOaMCHkHubmOEaPNtVbgbfhUYyxfedQmrPfCWFPkgJHjV\helloworld.ps1
will result in an error finding 'Powershell'.
This issue has been ongoing with several
Reproduction
Steps 3 and 4 of https://danefalvo.octopus.app/app#/Spaces-1/projects/deploylongpackage/deployments/process/steps?actionId=d21f920e-9e56-4879-99c7-a815f4f4b177
Step 3 and 4 use the same package, same worker, etc. Step 4's powershell script is located in a long folder path.
Error and Stacktrace
Step 3
23:18:10 Verbose | Extracting package to: C:\Octopus\Tentacle\Work\20221122231806-111088-36\staging
23:18:10 Verbose | Extracted 10 files
23:18:10 Info | Extracting package 'C:\Octopus\Tentacle\Files\[email protected]@F021AC3268F02A438AB385932213938A.nupkg' to 'C:\Octopus\Tentacle\Work\20221122231806-111088-36\staging'
23:18:10 Verbose | Performing variable substitution on 'C:\Octopus\Tentacle\Work\20221122231806-111088-36\staging\content\AppData\Test File.ps1'
<REDACTED FOR BREVITY>
23:18:33 Verbose | Successfully authenticated with the Azure CLI
23:18:33 Verbose | Invoking target script C:\Octopus\Tentacle\Work\20221122231806-111088-36\staging\content\AppData\Octopus.FunctionAppenderContext.ps1 with parameters
23:18:33 Verbose | Invoking target script C:\Octopus\Tentacle\Work\20221122231806-111088-36\staging\content\AppData\Test File.ps1 with parameters.
23:18:38 Info | hey
Step 4
23:18:44 Verbose | Extracting package to: C:\Octopus\Tentacle\Work\20221122231840-111088-38\staging
23:18:44 Verbose | Extracted 10 files
23:18:44 Info | Extracting package 'C:\Octopus\Tentacle\Files\[email protected]@F021AC3268F02A438AB385932213938A.nupkg' to 'C:\Octopus\Tentacle\Work\20221122231840-111088-38\staging'
23:18:44 Verbose | Performing variable substitution on 'C:\Octopus\Tentacle\Work\20221122231840-111088-38\staging\content\AppData\pXpVfbqAQksSSAPXwbTQVtKxOCgxrcdfMtWbqbBFBNpJnYrDKvKVQQNerWfKAcqUovXDmVYcVMCnCpJTHJeUyBpHDEfuYWVokNfH\kBOcwsKGTabUbQjdcACQKtPSaApnzBEWhzjkvKfjQzkxQuAQjysDAkwNnNwRskUFNvDcsWsWMaAefAJjohkyZWAPxtmbNFtwMBtS\AYhbjhguKAbVfVrYegeqQwfCMMhDmJodrJHDKMMrEKAfEVsSSKWKMzGZOaMCHkHubmOEaPNtVbgbfhUYyxfedQmrPfCWFPkgJHjV\test.ps1'
23:18:44 Verbose | Executing 'C:\Octopus\Tentacle\Work\20221122231840-111088-38\staging\content\AppData\pXpVfbqAQksSSAPXwbTQVtKxOCgxrcdfMtWbqbBFBNpJnYrDKvKVQQNerWfKAcqUovXDmVYcVMCnCpJTHJeUyBpHDEfuYWVokNfH\kBOcwsKGTabUbQjdcACQKtPSaApnzBEWhzjkvKfjQzkxQuAQjysDAkwNnNwRskUFNvDcsWsWMaAefAJjohkyZWAPxtmbNFtwMBtS\AYhbjhguKAbVfVrYegeqQwfCMMhDmJodrJHDKMMrEKAfEVsSSKWKMzGZOaMCHkHubmOEaPNtVbgbfhUYyxfedQmrPfCWFPkgJHjV\test.ps1'
23:18:44 Verbose | Setting Proxy Environment Variables
23:18:44 Error | Unable to execute C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe, please ensure that C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe is installed and is in the PATH.
23:18:44 Error | System.Exception: Error when attempting to execute C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe: An error occurred trying to start process 'C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe' with working directory 'C:\Octopus\Tentacle\Work\20221122231840-111088-38\staging\content\AppData\pXpVfbqAQksSSAPXwbTQVtKxOCgxrcdfMtWbqbBFBNpJnYrDKvKVQQNerWfKAcqUovXDmVYcVMCnCpJTHJeUyBpHDEfuYWVokNfH\kBOcwsKGTabUbQjdcACQKtPSaApnzBEWhzjkvKfjQzkxQuAQjysDAkwNnNwRskUFNvDcsWsWMaAefAJjohkyZWAPxtmbNFtwMBtS\AYhbjhguKAbVfVrYegeqQwfCMMhDmJodrJHDKMMrEKAfEVsSSKWKMzGZOaMCHkHubmOEaPNtVbgbfhUYyxfedQmrPfCWFPkgJHjV'. The directory name is invalid.
23:18:44 Error | ---> System.ComponentModel.Win32Exception (267): An error occurred trying to start process 'C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe' with working directory 'C:\Octopus\Tentacle\Work\20221122231840-111088-38\staging\content\AppData\pXpVfbqAQksSSAPXwbTQVtKxOCgxrcdfMtWbqbBFBNpJnYrDKvKVQQNerWfKAcqUovXDmVYcVMCnCpJTHJeUyBpHDEfuYWVokNfH\kBOcwsKGTabUbQjdcACQKtPSaApnzBEWhzjkvKfjQzkxQuAQjysDAkwNnNwRskUFNvDcsWsWMaAefAJjohkyZWAPxtmbNFtwMBtS\AYhbjhguKAbVfVrYegeqQwfCMMhDmJodrJHDKMMrEKAfEVsSSKWKMzGZOaMCHkHubmOEaPNtVbgbfhUYyxfedQmrPfCWFPkgJHjV'. The directory name is invalid.
23:18:44 Error | at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
23:18:44 Error | at System.Diagnostics.Process.Start()
23:18:44 Error | at Calamari.Common.Features.Processes.SilentProcessRunner.ExecuteCommand(String executable, String arguments, String workingDirectory, Dictionary`2 environmentVars, String userName, SecureString password, Action`1 output, Action`1 error) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\SilentProcessRunner.cs:line 158
23:18:44 Error | --- End of inner exception stack trace ---
23:18:44 Error | at Calamari.Common.Features.Processes.SilentProcessRunner.ExecuteCommand(String executable, String arguments, String workingDirectory, Dictionary`2 environmentVars, String userName, SecureString password, Action`1 output, Action`1 error) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\SilentProcessRunner.cs:line 173
23:18:44 Error | at Calamari.Common.Features.Processes.CommandLineRunner.Execute(CommandLineInvocation invocation) in C:\BuildAgent\work\e0cefbed4ad11812\source\Calamari.Common\Features\Processes\CommandLineRunner.cs:line 28
23:18:44 Error | The command that caused the exception was: "C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe" -NoLogo -NonInteractive -ExecutionPolicy Unrestricted -Command "Set-PSDebug -Trace 0;Try {. {. 'C:\Octopus\Tentacle\Work\20221122231840-111088-38\staging\content\AppData\pXpVfbqAQksSSAPXwbTQVtKxOCgxrcdfMtWbqbBFBNpJnYrDKvKVQQNerWfKAcqUovXDmVYcVMCnCpJTHJeUyBpHDEfuYWVokNfH\kBOcwsKGTabUbQjdcACQKtPSaApnzBEWhzjkvKfjQzkxQuAQjysDAkwNnNwRskUFNvDcsWsWMaAefAJjohkyZWAPxtmbNFtwMBtS\AYhbjhguKAbVfVrYegeqQwfCMMhDmJodrJHDKMMrEKAfEVsSSKWKMzGZOaMCHkHubmOEaPNtVbgbfhUYyxfedQmrPfCWFPkgJHjV\Bootstrap.Octopus.AzureContext.ps1' -OctopusKey '50TmmlGZRH5swzEAGgagEw=='; if ((test-path variable:global:lastexitcode)) { exit $LastExitCode }};} catch { throw }"
More Information
This issue has been ongoing with various steps to fix this permanently.
To recap: This was one of the first issues - which is easily followable: https://github.com/OctopusDeploy/Issues/issues/4204
Although this rectified part of the issue - there was still an issue with extracting the package and it was chalked down to 'SharpCompress' not handling longfilepaths.
Additionally, all Dynamic Workers had 'LongFilePath compatibility' enabled.
This was rectified recently with a SharpCompress update. On trying the repro again, I have ended up with this error. So hopefully it's the last part of the fix, required to handle long paths correctly.
Workaround
Shorten the folder path.