aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Assistance troubleshooting sam local invoke

Open oldnerd opened this issue 9 years ago • 25 comments

I'm trying to use sam local invoke to simulate an S3 event. When I try and run the sam local invoke command "sam local invoke -e event.json --debug-port 5858 ExampleFunction"

I get an error message "unable to use container host config override file from '$HOME/.config/aws-sam-local/container-config.json': HOME env variable is not set"

Where should the HOME environment variable be set? I assume I'm doing something silly....

oldnerd avatar Aug 22 '17 00:08 oldnerd

Hi, @oldnerd - are you running this on Windows?

Can you post the full log? That message is purely informational, and shouldn't prevent SAM Local running in any way.

PaulMaddox avatar Aug 22 '17 08:08 PaulMaddox

I had the same issue. I set the HOME env on Windows. Now I get error related to unrecognized volume. I am running on Windows 7 with Docker Toolbox for Windows installed. Here is the error message: C:\Users\gaurav_kamdar\go\src\github.com\awslabs\aws-sam-local\test\templates\sam-official-samples\hello_world>sam local invoke "HelloWorld" -e event.json 2017/08/24 13:26:44 Successfully parsed template.yaml (version 2010-09-09) ←[34mINFO←[0m[0000] Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows 2017/08/24 13:26:44 Connected to Docker 1.28 ←[34mINFO←[0m[0000] Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows 2017/08/24 13:26:44 Fetching lambci/lambda:nodejs4.3 image for nodejs4.3 runtime... nodejs4.3: Pulling from lambci/lambda Digest: sha256:edc847ee95644b772b82c81202b0e5f9279f369bac2d5df74b4e9ce67d709b63 Status: Image is up to date for lambci/lambda:nodejs4.3 2017/08/24 13:26:44 Invoking index.handler (nodejs4.3) 2017/08/24 13:26:44 Could not invoke function: Error response from daemon: invalid bind mount spec "C:/Users/gaurav_kamdar/go/src/github.com/awslabs/aws-sam-local /test/templates/sam-official-samples/hello_world:/var/task:ro": invalid volume specification: 'C:/Users/gaurav_kamdar/go/src/github.com/awslabs/aws-sam-local/test /templates/sam-official-samples/hello_world:/var/task:ro'

gkamdar avatar Aug 24 '17 17:08 gkamdar

Any update on this? Where is the exact location to set $HOME variable? I'm running Windows 10 build 16281.

$ sam local invoke helloworld -e .\event-file.json 2017/09/17 20:41:16 Successfully parsed template.yml 2017/09/17 20:41:16 Connected to Docker 1.30 2017/09/17 20:41:16 Fetching lambci/lambda:nodejs6.10 image for nodejs6.10 runtime... nodejs6.10: Pulling from lambci/lambda cf9c84c367d8: Pull complete aeeaf5aea2af: Pull complete a0458750b065: Pull complete 4315c1ddcefe: Pull complete Digest: sha256:b9a57b98dcfe226cac3fb0b8329594eefb62ba7089fa27cf8ac968e5736cc04a Status: Downloaded newer image for lambci/lambda:nodejs6.10 2017/09/17 20:43:46 Invoking index.handler (nodejs6.10) 2017/09/17 20:43:46 unable to use container host config override file from '$HOME/.config/aws-sam-local/container-config.json': HOME env variable is not set

@PaulMaddox I just read through code a bit, seems like it will return early if it cannot find HOME variable. https://github.com/awslabs/aws-sam-local/blob/28eacbdd299917b2cceeb9444fe22bd57d33d97d/runtime.go#L243-L246

tulis avatar Sep 17 '17 11:09 tulis

I need to grab a Windows machine to debug. But looking at the code, it just prints and skips the override if HOME isn't present - https://github.com/awslabs/aws-sam-local/blob/develop/runtime.go#L247

sanathkr avatar Sep 21 '17 00:09 sanathkr

Getting same error on windows 10 with docker toolbox. S3 event Error:

C:\Users\bashwin\workspace>sam local invoke --event event.csv "ProcessorFunction" A newer version of the AWS SAM CLI is available! Your version: 0.2.0 Latest version: 0.2.2 See https://github.com/awslabs/aws-sam-local for upgrade instructions

2017/10/05 12:02:56 Successfully parsed template.yml INFO[0001] Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows 2017/10/05 12:02:56 Connected to Docker 1.32 INFO[0001] Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows 2017/10/05 12:02:56 Fetching lambci/lambda:java8 image for java8 runtime... java8: Pulling from lambci/lambda Digest: sha256:5e1f24ebf98bf010e94e8eb7d3eeec3d24d2a7d97a458756dda27134de526aa2 Status: Image is up to date for lambci/lambda:java8 2017/10/05 12:03:00 Invoking com.manthan.realtime.restresource.LambdaKPIResourceHandler (java8) 2017/10/05 12:03:00 Could not invoke function: Error response from daemon: invalid bind mount spec "C:/Users/bashwin/workspace:/var/task:ro": invalid volume specification: 'C:/Users/bashwin/workspace:/var/task:ro'

API Gateway Error:

Goes fine with mounting but the url 127.0.0.1:3000 gives below error { "message": "Internal server error" }

if i put any sysout it is not printing ...

Did anyone got it working? not able to proceed any further. Any help is much appreciated

ashwinbiyani avatar Oct 05 '17 06:10 ashwinbiyani

Also experiencing the same issue. Would appreciate assistance in getting over this roadblock.

jofo8948 avatar Oct 26 '17 08:10 jofo8948

Fix incoming soon!

PaulMaddox avatar Oct 31 '17 21:10 PaulMaddox

I'm having the same issue. Looks like SAM Local is referencing the $HOME environment variables on Windows for the home directory, while in some cases, this environment variables are not set.

zhangzhx avatar Nov 02 '17 20:11 zhangzhx

I had the same issue, I added HOME in environment variable and pointed it to "C:\Users<username>"

kaarthikeyansp avatar Nov 06 '17 13:11 kaarthikeyansp

I tried: SET HOME=%USERPROFILE% This got a step further, then failed with: Could not invoke function: Error response from daemon: invalid volume specification

ryaneliseislalom avatar Nov 08 '17 19:11 ryaneliseislalom

We have a fix for this coming. The development work is done and currently awaiting code review (see the above referenced pull request).

PaulMaddox avatar Nov 08 '17 22:11 PaulMaddox

This fix is included in the latest release (v0.2.3). Use npm update -g aws-sam-local to upgrade.

PaulMaddox avatar Dec 07 '17 20:12 PaulMaddox

is this supposed to be fixed? I just installed sam local today on win10 and getting this same error.

red8888 avatar Jan 18 '18 00:01 red8888

Did you npm update as described above? Are you using 0.2.3 or newer?

ryaneliseislalom avatar Jan 18 '18 00:01 ryaneliseislalom

I just installed version 0.2.6 and I get the same error on Win10. I used the workaround suggested by kaarthikeyansp above, and the error went away.

christian-boks avatar Feb 02 '18 08:02 christian-boks

Same exact scenario and result as @christian-boks here.

rogersp avatar Feb 10 '18 00:02 rogersp

Sorry to budge in... thought you might like to know I had same problem (possibly different scenario), upgrading docker + docker-machine solved this particular problem. Cheers

eetay avatar Mar 19 '18 16:03 eetay

I still get the same error on 0.2.10

lucasdluengo avatar Apr 09 '18 15:04 lucasdluengo

Error above same Aws-sam-local version 0.2.11

Mounting serviceless.instances.EC2InternalHandler::handleRequest (java8) at http://127.0.0.1:3000/{proxy+} [OPTIONS GET HEAD POST PUT DELETE PATCH]

You can now browse to the above endpoints to invoke your functions.
You do not need to restart/reload SAM CLI while working on your functions,
changes will be reflected instantly/automatically. You only need to restart
SAM CLI if you update your AWS SAM template.

2018/04/24 18:52:23 Invoking serviceless.instances.EC2InternalHandler::handleRequest (java8)
2018/04/24 18:52:23 Mounting /c/Users/serviceless as /var/task:ro inside runtime container
2018/04/24 18:52:23 unable to use container host config override file from '$HOME/.config/aws-sam-local/container-config.json': HOME env variable is not set
START RequestId: dda52335-90cf-4d24-9b3f-fc59f12e4d52 Version: $LATEST
java.lang.ClassNotFoundException: serviceless.instances.EC2InternalHandler
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)

rchatsiri avatar Apr 24 '18 11:04 rchatsiri

I also still see same error on windows 10. I set HOME as environment variable so that particular error went away but now i am getting this Could not invoke function: Error response from daemon: error while creating mount source path /host_mnt/<PATH> : mkdir /host_mnt/c: file exists

ShahDevanshi avatar May 04 '18 13:05 ShahDevanshi