The module './OctopusApplications' could not be loaded. For more information , run 'Import-Module ./OctopusApplicati ons'

Using Octopus Deploy Offline Package Drop to deploy a Windows Service, I am getting the following error log when deploying:

##octopus[stdout-default]
##octopus[stdout-verbose]
PowerShell Environment Information:
OperatingSystem: Microsoft Windows NT 6.3.9600.0
OsBitVersion: x64
Is64BitProcess: True
CurrentUser: XXX
MachineName: XXX
ProcessorCount: 2
CurrentDirectory: C:\Install\Octopus\XXX\OctopusApplications\XXX\XXX\XXX\XXX
CurrentLocation: C:\Install\Octopus\XXX.XXX.XXX.OfflinePackage.10.0.192-s
ync-only\OctopusApplications\XXX\XXX\XXX\XXX
TempDirectory: C:\Users\XXX\AppData\Local\Temp
HostProcessName: powershell
TotalPhysicalMemory: 16776628 KB
AvailablePhysicalMemory: 1785692 KB
##octopus[stdout-default]
. : The module ‘./OctopusApplications’ could not be loaded. For more information
, run ‘Import-Module ./OctopusApplicati
ons’.
At C:\Install\Octopus\XXX.XXX.XXX.OfflinePackage.10.0.192-sync-only\Octopus
Applications\XXX\XXX\XXX\XXX\Bootstrap.Octopus.Features.WindowsService_AfterPreDeploy.ps1
:4299 char:3

  • . './OctopusApplications\XXX\XXX\XXX\10.0.48-sync-onl 

  • + CategoryInfo          : ObjectNotFound: (./OctopusApplic...erPreDeploy.ps1
    

:String) [], ParentContainsErrorRecord
Exception
+ FullyQualifiedErrorId : CouldNotAutoLoadModule

Script ‘./OctopusApplications\XXX\XXX\XXX\XXX\Octo
pus.Features.WindowsService_AfterPreDeploy.ps1’ returned non-zero exit code: 1
Running rollback conventions

##octopus[stdout-verbose]
Deleting ‘./OctopusApplications\XXX\XXX\XXX\XXX\Oc
topus.Features.WindowsService_AfterPreDeploy.ps1’
Adding journal entry:



Script ‘./OctopusApplications\XXX\XXX\XXX\XXX\Octo
pus.Features.WindowsService_AfterPreDeploy.ps1’ returned non-zero exit code: 1

What’s going on here? The XXX_AfterPredeploy.ps1 script tries to find a powershell module named “./OctopusApplications”? I don’t have any custom pre or deployment scripts defined for the step (only have a post deploy script defined). Unfortunately the Octo
pus.Features.WindowsService_AfterPreDeploy.ps1 file seems to be deleted after the deployment attempt so I cannot inspect the file either.

Note that the same deployment works fine using online tentacle deployment. If I switch to Offline Package drop I get the above error. I have tried this on at least 2 different environments with the same result.

Hi @dennis.rosen,

Thanks for reaching out :slight_smile:

What’s going on here? The XXX_AfterPredeploy.ps1 script tries to find a powershell module named “./OctopusApplications”? I don’t have any custom pre or deployment scripts defined for the step (only have a post deploy script defined).

OctopusAplications seems to be a module that’s sitting on your server(s) that’s failing to load. The mystery is why it only fails to load when it gets imported via an Offline Package Drop(OPD). Couple of questions to aid in the troubleshooting:

  • Have you tried logging into one of the VMs where you are getting this error and looking for that module using Get-Module -ListAvailable to see where that module is at and if you can import it using import-module?
  • Is it possible that there’s an Import-Module call in a Powershell Profile File that’s being executed when you run the OPD.
  • If you create an ODP that just contains a single Powershell Script step that contains write-host "Hello world", do you get the same error?

Unfortunately the Octo
pus.Features.WindowsService_AfterPreDeploy.ps1 file seems to be deleted after the deployment attempt so I cannot inspect the file either.

Yes, we delete that bootstrap file after the deployment finishes.

Looking forward to hear about your findings!

Dalmiro

Hi,

There is no powershell module called OctopusApplications in any environment. I’m not sure about my Powershell Profile File. If I run $PROFILE in powershell to get the path to the profile file I get a non-existing path, so not sure where to look.

I think if I create an ODP with just a Powershell script it would run fine, since the error only occurs when deploying a Windows Service. I have several IIS Web Applications that deploy fine during the ODP deploy (that each runs some powershell scripting in their postdeploy), it’s only the Windows Services that fails.

Any update on this? This issue is making Octopus Deploy unusable for deployments.

Hi Dennis,

Would it be possible for you to create an ODP with just that powershell script, and send us the ODP to Lumanox Web App

Additionally, could you create an ODP with a single Windows Service step and also upload it to that secure link?

And Finally, if you can also upload the original ODP that’s running into this issue, it’d be helpful.

I think the only way to know what’s happening at this point is to take a look at what’s wrong with those ODPs manually.

Thanks,
Dalmiro

I figured out where the error comes from. In my offline package drop deployment target I have Applications Directory set to ‘./OctopusApplications’. It seems like Octopus Deploy does not support relative paths here? I also tried ‘.\OctopusApplications’ with the same error. If I change to an absolute path the deployment works. Ideally I would like the Applications Directory to be relative to where I unzip the deployment package. Otherwise I will have to create quite a few Offline Package Drop deployment targets with different Applications Directories (one per tenant per environment pretty much).

1 Like

Does $PSScriptRoot/OctopusApplications work in this case?