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.

SAM CLI on Windows / WSL2 and Ubuntu

See original GitHub issue

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shopizer-ecommercecommented, Apr 21, 2022

Sorry, i thought i already submitted the whole story. Anyway here is what i have experienced

OS windows 10 entreprise WSL2 ubuntu 20 Docker desktop with WSL2 option

Followed the installation for Linux as described in the documentation https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-linux.html

SAM cli version /usr/local/bin/sam --version SAM CLI, version 1.46.0

Ran sam init hello world (option 1)

Tried 2 different runtimes 8 - nodejs14.x 9 - nodejs12.x


Generating application:
-----------------------
Name: sam-app
Runtime: nodejs12.x
Architectures: x86_64
Dependency Manager: npm
Application Template: hello-world
Output Directory: .

sam local invoke fails as well as subsequent sam build commands

Invoking app.lambdaHandler (nodejs12.x) Image was not found. Removing rapid images for repo public.ecr.aws/sam/emulation-nodejs12.x Building image… Skip pulling image and use local one: public.ecr.aws/sam/emulation-nodejs12.x:rapid-1.46.0-x86_64.

Mounting /mnt/c/WebDevelopment/repo/sam/sam-app/sam-app/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container START RequestId: a406a014-84c7-45b0-ba59-3eda6e001c14 Version: $LATEST {“statusCode”:200,“body”:“{"message":"hello world"}”}END RequestId: a406a014-84c7-45b0-ba59-3eda6e001c14 REPORT RequestId: a406a014-84c7-45b0-ba59-3eda6e001c14 Init Duration: 0.28 ms Duration: 188.03 ms Billed Duration: 189 ms Memory Size: 128 MB Max Memory Used: 128 MB Traceback (most recent call last): File “samcli/main.py”, line 12, in <module> File “click/core.py”, line 829, in call File “click/core.py”, line 782, in main File “click/core.py”, line 1259, in invoke File “click/core.py”, line 1259, in invoke File “click/core.py”, line 1066, in invoke File “click/core.py”, line 610, in invoke File “click/decorators.py”, line 73, in new_func File “click/core.py”, line 610, in invoke File “samcli/lib/telemetry/metric.py”, line 146, in wrapped File “samcli/lib/iac/cdk/utils.py”, line 27, in is_cdk_project File “samcli/lib/iac/cdk/utils.py”, line 73, in _relevant_cdk_files_are_present FileNotFoundError: [Errno 2] No such file or directory [11624] Failed to execute script main

0reactions
Rabadash8820commented, Oct 4, 2022

Looking at the source code, the line that’s failing is calling os.getcwd(). Based on this SO post, getcwd can fail if its inside a deleted directory, which maybe happens here if the directory is removed after the Function ends?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to run sam cli on Windows Subsystem for Linux 2
I was able to install and use AWS SAM for WSL2 with Ubuntu 20.04.4 LTS. Share. Share a link to this answer. Copy...
Read more >
Installing the AWS SAM CLI - AWS Serverless Application Model
This section describes how to install the AWS SAM CLI on macOS, Windows, and Linux.
Read more >
SAM CLI integration has trouble with WSL #2056 - GitHub
The issue is in windows-land, docker linux-izes your mount paths, and then they sort of work for mounting if they are a direct...
Read more >
FAQ's about Windows Subsystem for Linux - WSL
Using Bash, you can run command-line Linux tools and apps. ... Sam can enable WSL (& WSL 2 to improve speed and performance),...
Read more >
Lambda: using AWS SAM Local to test ... - marcesher.com
AWS SAM Local is a “CLI tool for local development and testing of ... to use it in Windows Subsystem for Linux (WSL)...
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