Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot debug gitea in vscodium + default vscode-go 0.30.0 config #18394

Closed
pboguslawski opened this issue Jan 24, 2022 · 12 comments · Fixed by #18397
Closed

Cannot debug gitea in vscodium + default vscode-go 0.30.0 config #18394

pboguslawski opened this issue Jan 24, 2022 · 12 comments · Fixed by #18397
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented

Comments

@pboguslawski
Copy link
Contributor

pboguslawski commented Jan 24, 2022

Gitea Version

1.16

Git Version

No response

Operating System

No response

How are you running Gitea?

Compilation from source.

Database

No response

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

When you try to compile gitea in vscodium with current vscode-go extension version 0.30.0 using instructions from

https://github.com/go-gitea/gitea/blob/main/contrib/ide/README.md

debug binary will be build in /tmp not in ${workspaceRoot} and page http://127.0.0.1:3000/ will display only

Unable to find status/500 template

and debug console will contain errors like

2022/01/24 19:02:18 ...ers/common/logger.go:21:1() [I] Started GET / for 127.0.0.1:34106
2022/01/24 19:02:18 ...s/context/context.go:206:HTML() [E] Render failed: html/template: "install" is undefined
2022/01/24 19:02:18 ...s/context/context.go:290:PlainTextBytes() [E] PlainTextBytes: Unable to find status/500 template
2022/01/24 19:02:18 ...ers/common/logger.go:30:1() [I] Completed GET / 500 Internal Server Error in 469.837µs

Problem is caused probably by new debugger mode used in vscode-go extension (dlv-dap).

Workaround that seems to work is to turn on legacy mode by adding

    "go.delveConfig": {
        "debugAdapter": "legacy",
    }

to settings.json.

Screenshots

No response

@Gusted
Copy link
Contributor

Gusted commented Jan 24, 2022

This seems to be a issue with the stable version of vscode-go, I don't encounter such issue with the preview version of vscode-go, Could you try go nightly?

@zeripath
Copy link
Contributor

zeripath commented Jan 24, 2022

I suspect that the new configuration does not set the correct working directory.

I think this might be indicating a bug though - I suspect that:

Directory: "templates",

Should actually be:

		Directory:                 path.Join(setting.AppWorkPath, "/templates"),

@Gusted
Copy link
Contributor

Gusted commented Jan 24, 2022

@zeripath Applied the patch - same error.

@Gusted Gusted added type/upstream This is an issue in one of Gitea's dependencies and should be reported there issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented labels Jan 24, 2022
@zeripath
Copy link
Contributor

add "-w=${workspaceRoot}" to the args

@zeripath
Copy link
Contributor

and the patch

@Gusted
Copy link
Contributor

Gusted commented Jan 24, 2022

Same error, different values:

2022/01/24 22:43:23 ...s/context/context.go:207:HTML() [E] Render failed: html/template: "user/dashboard/dashboard" is undefined
2022/01/24 22:43:23 ...s/context/context.go:291:PlainTextBytes() [E] PlainTextBytes: Unable to find status/500 template
2022/01/24 22:43:23 router: completed GET / for 127.0.0.1:34588, 500 Internal Server Error in 7.6ms @ web/home.go:26(web.Home)
2022/01/24 22:43:23 router: completed GET /favicon.ico for 127.0.0.1:34588, 200 OK in 0.9ms @ user/profile.go:51(user.Profile)

@lafriks
Copy link
Member

lafriks commented Jan 24, 2022

this works for me:

    {
      "name": "Launch",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "buildFlags": "",
      "program": "${workspaceRoot}/main.go",
      "env": {
        "GITEA_WORK_DIR": "${workspaceRoot}",
      },
      "args": ["web"],
      "cwd": "${workspaceRoot}",
      "showLog": true
    },

There was change that resulting executable binary is now located in temp directory so gitea AppPath and so also AppWorkDir is temp directory. Setting environment variable GITEA_WORK_DIR to "${workspaceRoot}"` fixes this problem

@Gusted Gusted removed the type/upstream This is an issue in one of Gitea's dependencies and should be reported there label Jan 24, 2022
@zeripath
Copy link
Contributor

zeripath commented Jan 24, 2022

I think the cwd is what is fixing this and the GITEA_WORK_DIR

@lafriks
Copy link
Member

lafriks commented Jan 24, 2022

cwd is not really fixing imho, just left it just in case (I think it's even defaults to this value already). Problem is that apppath and workdir for us is historically directory where binary is located

@zeripath
Copy link
Contributor

so:

        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "buildFlags": "-tags='sqlite sqlite_unlock_notify'",
            "program": "${workspaceRoot}/main.go",
            "env": {
              "GITEA_WORK_DIR": "${workspaceRoot}",
            },
            "args": ["web"],
            "cwd": "${workspaceRoot}",
            "showLog": true
        },

is now working for me.

@lafriks
Copy link
Member

lafriks commented Jan 24, 2022

just tested it works also without cwd as it defaults to program directory by default

@zeripath
Copy link
Contributor

interesting - now why doesn't -w do the same thing

@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants