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.

VS Code Insiders Remote WSL - Permission denied: '.aws-sam'

See original GitHub issue

Issue Type: Bug

Problem

Using Remote WSL in VS Code Insiders, AWS Toolkit errors when running Lambda debug configurations. This was working fine a couple days ago, but is now failing, and I’m not sure what changed. It works fine in non-Insiders VS Code, and I’m able to invoke the function via SAM CLI just fine.

I’ve tried uninstalling/re-installing both the AWS Toolkit and WSL Remote extensions, but the error persists.

Steps to reproduce the issue

  1. Use sam init to create a sample Serverless Application from the hello world template using nodejs 16.x and Zip package type.
  2. Add a debug configuration using the CodeLens from app.js or template.yaml.
  3. Run the new debug configuration.
  4. See in output: “Error: NodejsNpmBuilder:CopyDependencies - [Errno 13] Permission denied: ‘.aws-sam’”

Expected behavior

Debug configuration should not error.

Error details from AWS Toolkit log with debug level logging enabled

AWS Toolkit Log
2022-07-08 09:37:26 [INFO]: Preparing to debug locally: Lambda "app.lambdaHandler"
2022-07-08 09:37:26 [INFO]: Building SAM application...
2022-07-08 09:37:26 [INFO]: Command: (not started) [/usr/local/bin/sam build --debug --build-dir /tmp/aws-toolkit-vscode/vsctk3ZW4KZ/output --template /home/adam/src/rgapi/test-toolkit/template.yaml]
2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,595 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,595 | Using config file: samconfig.toml, config environment: default
2022-07-08 09:37:26,595 | Expand command line arguments to:
2022-07-08 09:37:26,595 | --template_file=/home/adam/src/rgapi/test-toolkit/template.yaml --build_dir=/tmp/aws-toolkit-vscode/vsctk3ZW4KZ/output --cache_dir=.aws-sam/cache 

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,735 | 'build' command is called

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,739 | No Parameters detected in the template

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,751 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,752 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,753 | 0 stacks found in the template

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,753 | No Parameters detected in the template

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,763 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,763 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2022-07-08 09:37:26,763 | 2 resources found in the stack 
2022-07-08 09:37:26,763 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello-world/'
2022-07-08 09:37:26,763 | --base-dir is not presented, adjusting uri hello-world/ relative to /home/adam/src/rgapi/test-toolkit/template.yaml

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,768 | Your template contains a resource with logical ID "ServerlessRestApi", which is a reserved logical ID in AWS SAM. It could result in unexpected behaviors and is not recommended.

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,768 | Instantiating build definitions

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,768 | No previous build graph found, generating new one
2022-07-08 09:37:26,768 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(nodejs16.x, /home/adam/src/rgapi/test-toolkit/hello-world, Zip, , 90a16d73-c182-4a64-abdf-e26f61097619, {}, {}, x86_64, []), Function: Function(function_id='HelloWorldFunction', name='HelloWorldFunction', functionname='HelloWorldFunction', runtime='nodejs16.x', memory=None, timeout=3, handler='app.lambdaHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/home/adam/src/rgapi/test-toolkit/hello-world', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'Api', 'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'SamResourceId': 'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, stack_path=''))

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,769 | Building codeuri: /home/adam/src/rgapi/test-toolkit/hello-world runtime: nodejs16.x metadata: {} architecture: x86_64 functions: HelloWorldFunction
2022-07-08 09:37:26,769 | Building to following folder /tmp/aws-toolkit-vscode/vsctk3ZW4KZ/output/HelloWorldFunction

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,770 | Loading workflow module 'aws_lambda_builders.workflows'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,772 | Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,773 | Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,774 | Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,776 | Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,777 | Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,778 | Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,779 | Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,780 | Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,781 | Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,781 | Found workflow 'NodejsNpmBuilder' to support capabilities 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,792 | Running workflow 'NodejsNpmBuilder'

2022-07-08 09:37:26 [INFO]: 2022-07-08 09:37:26,793 | Running NodejsNpmBuilder:NpmPack
2022-07-08 09:37:26,793 | NODEJS packaging file:/home/adam/src/rgapi/test-toolkit/hello-world to /tmp/tmpb2iy3rtb
2022-07-08 09:37:26,793 | executing NPM: ['npm', 'pack', '-q', 'file:/home/adam/src/rgapi/test-toolkit/hello-world']

2022-07-08 09:37:27 [INFO]: 2022-07-08 09:37:27,011 | NODEJS packed to hello_world-1.0.0.tgz

2022-07-08 09:37:27 [INFO]: 2022-07-08 09:37:27,011 | NODEJS extracting to /tmp/tmpb2iy3rtb/unpacked

2022-07-08 09:37:27 [INFO]: 2022-07-08 09:37:27,013 | NodejsNpmBuilder:NpmPack succeeded
2022-07-08 09:37:27,013 | Running NodejsNpmBuilder:CopyNpmrcAndLockfile
2022-07-08 09:37:27,013 | NodejsNpmBuilder:CopyNpmrcAndLockfile succeeded
2022-07-08 09:37:27,013 | Running NodejsNpmBuilder:CopySource
2022-07-08 09:37:27,013 | Creating target folders at /tmp/aws-toolkit-vscode/vsctk3ZW4KZ/output/HelloWorldFunction

2022-07-08 09:37:27 [INFO]: 2022-07-08 09:37:27,013 | Copying directory metadata from source (/tmp/tmpb2iy3rtb/unpacked/package) to destination (/tmp/aws-toolkit-vscode/vsctk3ZW4KZ/output/HelloWorldFunction)

2022-07-08 09:37:27 [INFO]: 2022-07-08 09:37:27,013 | Copying source file (/tmp/tmpb2iy3rtb/unpacked/package/package.json) to destination (/tmp/aws-toolkit-vscode/vsctk3ZW4KZ/output/HelloWorldFunction/package.json)
2022-07-08 09:37:27,013 | Copying source file (/tmp/tmpb2iy3rtb/unpacked/package/app.js) to destination (/tmp/aws-toolkit-vscode/vsctk3ZW4KZ/output/HelloWorldFunction/app.js)

2022-07-08 09:37:27 [INFO]: 2022-07-08 09:37:27,013 | NodejsNpmBuilder:CopySource succeeded
2022-07-08 09:37:27,013 | Running NodejsNpmBuilder:NpmInstall
2022-07-08 09:37:27,013 | NODEJS installing in: /tmp/aws-toolkit-vscode/vsctk3ZW4KZ/output/HelloWorldFunction
2022-07-08 09:37:27,013 | executing NPM: ['npm', 'install', '-q', '--no-audit', '--no-save', '--production', '--unsafe-perm']

2022-07-08 09:37:29 [INFO]: 2022-07-08 09:37:29,184 | NodejsNpmBuilder:NpmInstall succeeded

2022-07-08 09:37:29 [INFO]: 2022-07-08 09:37:29,184 | Running NodejsNpmBuilder:CleanUp
2022-07-08 09:37:29,185 | Clean up action: .aws-sam/deps/90a16d73-c182-4a64-abdf-e26f61097619 does not exist and will be skipped.
2022-07-08 09:37:29,185 | NodejsNpmBuilder:CleanUp succeeded
2022-07-08 09:37:29,185 | Running NodejsNpmBuilder:CopyDependencies

2022-07-08 09:37:29 [INFO]: 2022-07-08 09:37:29,185 | Creating target folders at .aws-sam/deps/90a16d73-c182-4a64-abdf-e26f61097619/node_modules

2022-07-08 09:37:29 [INFO]: 2022-07-08 09:37:29,186 | NodejsNpmBuilder:CopyDependencies raised unhandled exception
Traceback (most recent call last):
  File "aws_lambda_builders/workflow.py", line 301, in run
  File "aws_lambda_builders/actions.py", line 132, in execute
  File "aws_lambda_builders/utils.py", line 46, in copytree
  File "os.py", line 213, in makedirs
  File "os.py", line 213, in makedirs
  File "os.py", line 213, in makedirs
  File "os.py", line 223, in makedirs
PermissionError: [Errno 13] Permission denied: '.aws-sam'

2022-07-08 09:37:29 [INFO]: 
Build Failed

2022-07-08 09:37:29 [INFO]: 2022-07-08 09:37:29,191 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '6a18193a-3297-4491-a29d-f02b4d0cb52e', 'installationId': '09a62600-8123-4197-9982-c998dce3502c', 'sessionId': '2bbfe5fa-540e-42d0-84e7-593eb6221e5c', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.7.10', 'samcliVersion': '1.53.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN'}, 'duration': 2595, 'exitReason': 'WorkflowUnknownError', 'exitCode': 1}}]}

2022-07-08 09:37:29 [INFO]: 2022-07-08 09:37:29,554 | Telemetry response: 200

2022-07-08 09:37:29 [INFO]: Error: NodejsNpmBuilder:CopyDependencies - [Errno 13] Permission denied: '.aws-sam'

2022-07-08 09:37:29 [WARN]: "sam build" failed: /home/adam/src/rgapi/test-toolkit/template.yaml

System details

OS: Linux x64 5.10.102.1-microsoft-standard-WSL2 Visual Studio Code extension host: 1.69.0-insider AWS Toolkit: 1.45.0 node: 16.13.2

Extension version: 1.45.0 VS Code version: Code - Insiders 1.69.0-insider (92d25e35d9bf1a6b16f7d0758f25d48ace11e5b9, 2022-07-05T18:38:03.893Z) OS version: Windows_NT ia32 10.0.22621 Restricted Mode: No Remote OS version: Linux x64 5.10.102.1-microsoft-standard-WSL2

System Info
Item Value
CPUs AMD Ryzen 5 5600X 6-Core Processor (12 x 3700)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.93GB (16.16GB free)
Process Argv –crash-reporter-id c2d555f0-6f01-4c68-bb9b-5ccd8803c18f
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.10.102.1-microsoft-standard-WSL2
CPUs AMD Ryzen 5 5600X 6-Core Processor (12 x 3700)
Memory (System) 15.59GB (10.27GB free)
VM 0%
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
vsc_aa:30263845
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805:30301674
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30404738
wslgetstarted:30449409
vscscmwlcmt:30465136
cppdebug:30492333
pylanb8912:30522163
vsclangdf:30492506

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jonathanlaniadocommented, Jul 12, 2022

Thanks for your help. Your comment here did fix it for me, thank you! https://github.com/aws/aws-toolkit-vscode/issues/2395#issuecomment-1180813402

1reaction
JadenSimoncommented, Jul 11, 2022

@jonathanlaniado

Are you still experiencing this problem? If so, feel free to add a comment to https://github.com/aws/aws-toolkit-vscode/issues/2395 as I believe that issue closely related to this one albeit with a slightly different error message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developing in WSL - Visual Studio Code
for example: code --remote wsl+Ubuntu /home/jim/projects/c ... I see EACCES: permission denied error trying to rename a folder in the open workspace in...
Read more >
Permission issue with VSCode and WSL (code: command not ...
My error resolving was by click right button mouse on icon VS Code and chosen settings then "compatibility" tab and finaly disabled "run...
Read more >
awesome-vscode | A curated list of delightful VS Code ...
A curated list of delightful Visual Studio Code packages and resources. ... Project Dashboard; Rainbow CSV; Remote Development; Remote VSCode; REST Client ...
Read more >
Working with serverless applications - AWS Toolkit for VS Code
Learn how to create and use an AWS Serverless Application by using the AWS Toolkit for Visual Studio Code.
Read more >
Visual Studio Code Remote Development may change ...
Here I am doing a live debug session of a Rust app with zero setup other than VS Code Insiders, the Remote Extensions,...
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