question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vague error message if zip command is missing in AWSLambdaPSCore

See original GitHub issue

Description

When setting up AWSLambdaPSCore on a fresh EC2 instance running Ubuntu Server 20.04 LTS, some dependencies for the AWSLambdaPSCore module are not pre-installed. If you attempt to publish a PowerShell-based AWS Lambda function, you receive a very bizarre error message.

  • zip command is not installed by default

Expected Behavior

The Publish-AWSPowerShellLambda command should run dependency checks early on, before running the dotnet restore command, so that any missing utilities can be installed, and DOTNET_ROOT is set correctly. Any missing dependencies should be listed out, along with remediation commands, to provide a pleasant user experience for this command.

I’ve also come across an issue where libhostfxr.so could not be found. I think that’s somehow related to DOTNET_ROOT, but I’m not entirely sure, as I can’t seem to intentionally reproduce it. I think it had something to do with having .NET Core 5.0 installed, but not 3.1.

Here’s a list of dependency checks that I’m currently aware of, which should be executed each time an invocation of Publish-AWSPowerShellLambda is made:

  • .NET Core SDK installed
  • DOTNET_ROOT set correctly (if required)
  • libhostfxr.so can be located
  • zip command is installed

There may be other dependency checks that should be included as well, so please feel free to add them to this issue report.

Reproduction Steps

bash> sudo snap install powershell --classic
bash> pwsh
PS > Install-Module -Name AWSLambdaPSCore -Scope CurrentUser -Force
PS > Publish-AWSPowerShellLambda ..........
Zipping publish folder /tmp/generatetonsofdata.ps1/bin/Release/netcoreapp3.1/publish to /tmp/generatetonsofdata.ps1/bin/Release/netcoreapp3.1/generatetonsofdata.ps1.zip
Failed to find the "zip" utility program in path. This program is required to maintain Linux file permissions in the zip archive.
Exception: /home/ubuntu/.local/share/powershell/Modules/AWSLambdaPSCore/2.0.0.0/Private/_DeploymentFunctions.ps1:203
Line |
 203 |              throw $msg
     |              ~~~~~~~~~~
     | Error publishing PowerShell Lambda Function: 255 CALLSTACK: Command                     Arguments -------                     ---------
     | _deployProject              {ProfileName=, PowerShellFunctionHandler=, Region=, EnvironmentVariables=, Tags=, PublishNewVersion=, DisableInteractive=,
     | FunctionRole=arn:aws:iam::665453315… Publish-AWSPowerShellLambda {Name=generatetonsofdata, ScriptPath=./generatetonsofdata.ps1/generatetonsofdata.ps1.ps1,
     | IAMRoleArn=arn:aws:iam::665453315198:role/lambdaworkspacescleanup}    <ScriptBlock>               {}

Environment

Name                           Value
----                           -----
PSVersion                      7.1.2
PSEdition                      Core
GitCommitId                    7.1.2
OS                             Linux 5.4.0-1038-aws #40-Ubuntu SMP Fri Feb 5 23:50:40 UTC 2021
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Resolution

  • 👋 I can/would-like-to implement a fix for this problem myself

This is a 🐛 bug-report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ashishdhingracommented, Mar 9, 2021

@pcgeek86 Thanks for your response. I will convert this to feature-request and have developer look at it.

0reactions
github-actions[bot]commented, Aug 13, 2022

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handler missing on module 'awslambda' when code ...
To fix this: do not compress the folder (right-click -> compress), but open the folder, select all files and then right-click -> compress....
Read more >
zip files downloader not working when deployed on ...
Hi All, I've run into an issue with zipping files for download from a shiny app. This appears to be recent issue and...
Read more >
Missing or empty zip file (E:/Informatica/infa_shared/TgtFiles ...
This error occurs due to the syntax of the zip command. Solution ... In the above scenario, if the zip file is unzipped...
Read more >
How to Fix The Zip Extension and Unzip/7z Commands Are ...
If You Dont Have extension= zip Just add this Line 10. ... and Unzip/7z Commands Are Both Missing Skipping Laravel Windows Error Here...
Read more >
How to Resolve Message Cannot be Extracted Due to Missing ...
zip file is simply in the wrong location. To resolve this issue, locate the . zip file and move it to the correct...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found