Debugging packer with visual studio code

15 views
Skip to first unread message

Khai Do

unread,
Aug 28, 2019, 7:34:12 PM8/28/19
to Packer
I'm a newbie with both visual studio code, and Go. I have VS code (Version: 1.37.1) with the Go (ver 0.11.4) extension installed. I am attempting to debug packer with this setup however I cannot seem to make the debugger stop on a breakpoint. I have set '-debug' and PACKER_LOG=1. I think the problem is because packer uses panicwrap which seems to spawn a separate process to run packer and the VS code debugger doesn't have access to that process. I'm wondering if anybody else uses VS code to debug packer and whether they are able to debug packer code with it? I'm open to using other setup as well so I would also be interested in suggestions on how to setup debugging for packer development in general.  Thanks. 

Khai Do

unread,
Aug 28, 2019, 7:38:18 PM8/28/19
to Packer
Also this is my VS code launch configuration:


{
 
"version": "0.2.0",
 
"configurations": [
 
{
 
"name": "Launch",
 
"type": "go",
 
"request": "launch",
 
"mode": "auto",
 
"program": "${fileDirname}",
 
"env": {"PACKER_LOG": "1", "AWS_PROFILE": "itsandbox", "AWS_REGION": "us-east-1"},
 
"cwd": "/work/packer/test",
 
"args": ["build", "-debug", "-on-error=ask", "template.json"]
 
}
 
]
}


Rickard von Essen

unread,
Aug 29, 2019, 6:42:48 AM8/29/19
to packe...@googlegroups.com
Each plugin is running in a separate process and the communicates with RCP over a socket. So using a debugger will not work (be complicated at least).

But most of the Packer code is really simple and easy to follow with PACKER_LOG turned on. If that doesn't work adding some extra debug print outs when you have homed in on the problem is usually enough.

What are trying to do? 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/73d89fd6-1f70-4d09-be5b-5d3a86947722%40googlegroups.com.

Khai Do

unread,
Aug 29, 2019, 10:20:14 AM8/29/19
to packe...@googlegroups.com
I'm not trying to do anything specific yet I just wanted to prepare a
general development environment to make contributions which, for me,
includes a debugger. Thanks for the clarification Rickard but would
be nice to have this info in the documentation somewhere so I wouldn't
have to waste my time trying to figure out why debugging doesn't work
with packer.
> You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/sfmZootjHBU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to packer-tool...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CALz9Rt8Ko%3Dmnq%2BOamYOuYAtZ8DAFpkQSvw3cr_dUVRbfabtcng%40mail.gmail.com.

Rickard von Essen

unread,
Aug 29, 2019, 6:00:39 PM8/29/19
to packe...@googlegroups.com
> but would
be nice to have this info in the documentation somewhere so I wouldn't
have to waste my time trying to figure out why debugging doesn't work
with packer.

Yes that would be nice (but as always with open source software someone has to contribute that) 

Khai Do

unread,
Sep 1, 2019, 10:51:23 AM9/1/19
to Packer
>> To unsubscribe from this group and stop receiving emails from it, send an email to packe...@googlegroups.com.

>> To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/73d89fd6-1f70-4d09-be5b-5d3a86947722%40googlegroups.com.
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/sfmZootjHBU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to packe...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CALz9Rt8Ko%3Dmnq%2BOamYOuYAtZ8DAFpkQSvw3cr_dUVRbfabtcng%40mail.gmail.com.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages