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....
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.
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'
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
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
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
Also experiencing the same issue. Would appreciate assistance in getting over this roadblock.
Fix incoming soon!
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.
I had the same issue, I added HOME in environment variable and pointed it to "C:\Users\
I tried:
SET HOME=%USERPROFILE%
This got a step further, then failed with:
Could not invoke function: Error response from daemon: invalid volume specification
We have a fix for this coming. The development work is done and currently awaiting code review (see the above referenced pull request).
This fix is included in the latest release (v0.2.3).
Use npm update -g aws-sam-local to upgrade.
is this supposed to be fixed? I just installed sam local today on win10 and getting this same error.
Did you npm update as described above? Are you using 0.2.3 or newer?
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.
Same exact scenario and result as @christian-boks here.
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
I still get the same error on 0.2.10
Error above same Aws-sam-local version 0.2.11
[32;1mMounting serviceless.instances.EC2InternalHandler::handleRequest (java8) at http://127.0.0.1:3000/{proxy+} [OPTIONS GET HEAD POST PUT DELETE PATCH][0m
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
[32mSTART RequestId: dda52335-90cf-4d24-9b3f-fc59f12e4d52 Version: $LATEST[0m
[31mjava.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)
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
Bump. Sam version : SAM CLI, version 0.14.2, I set home variable from terminal, I am an administrator and the command prompt is running as an administrator (Windows 10 Pro, unfortunately Docker Toolbox as Hyper-V is broken). The error is:
Fetching lambci/lambda:nodejs8.10 Docker container image......
2019-04-15 11:02:51 Mounting c:\Intellij_Projs\sam-app\hello-world as /var/task:ro inside runtime container
[32mSTART RequestId: dd83a1f8-6b34-16e8-81b6-23598da70949 Version: $LATEST[0m
[31mUnable to import module 'app': Error[0m
[31m at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)[0m
"errorMessage":"Cannot find module '/var/task/app'","errorType":"Error","stackTrace":["Function.Module._load (module.js:474:25)","Module.require (module.js:596:17)","require (internal/module.js:11:18)"]}
this is on simple hello-world JS application produced by sam init. In case I am doing something wrong, I ran sam init. Changed into the directory sam-app and ran the command: sam local invoke HelloWorldFunction --event event.json
Thanks in advance
@ms-clovis Did you run sam build before invoke? Looks like Docker worked, but it is not finding the right files.
Sanathkr, yes ran build first
To reiterate this is is running docker server (using docker-machine) and this image:
Name type state URL Docker
box * virtualbox Running tcp://192.168.99.100:2376 v18.09.5
bump
I still get "unable to use container host config override file from '$HOME/.config/aws-sam-local/container-config.json': HOME env variable is not set" after get request "127.0.0.1:3000/ping" when use "sam local start-api --template sam.yaml".
This is my log:
"2020/02/28 10:22:06 Invoking com.amazonaws.serverless.proxy.struts2.Struts2LambdaHandler::handleRequest (java8)
2020/02/28 10:22:07 WARNING: No AWS credentials found. Missing credentials may lead to slow startup times as detailed in https://github.com/awslabs/aws-sam-local/issues/134
2020/02/28 10:22:07 Mounting /c/Users/huyho/OneDrive/Documents/Java Project/aws-serverless-struts2-archetype as /var/task:ro inside runtime container
2020/02/28 10:22:07 unable to use container host config override file from '$HOME/.config/aws-sam-local/container-config.json': HOME env variable is not set
2020/02/28 10:22:07 Error invoking java8 runtime: Error: No such image: lambci/lambda:java8 "
I have followed the guide in README.md. Please help me.
Most helpful comment
We have a fix for this coming. The development work is done and currently awaiting code review (see the above referenced pull request).