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

Does not work on GoLand #11

Open
fehnomenal opened this issue Apr 10, 2021 · 5 comments · May be fixed by #67
Open

Does not work on GoLand #11

fehnomenal opened this issue Apr 10, 2021 · 5 comments · May be fixed by #67
Assignees

Comments

@fehnomenal
Copy link
Owner

https://plugins.jetbrains.com/plugin/15285-direnv-integration/reviews#review=51879

@fehnomenal fehnomenal self-assigned this Apr 10, 2021
@fehnomenal fehnomenal changed the title Does not work on GoLand? Does not work on GoLand Apr 10, 2021
@fiksn
Copy link

fiksn commented Jun 26, 2021

I have the same issue with GoLand (and also IntelliJ IDEA).

Looked at the code:

        val process = executeDirenv(envrcFile, "export", "json")

        if (process.waitFor() != 0) {
            handleDirenvError(process, envrcFile)
            return
        }

        val notification = jsonFactory.createParser(process.inputStream).use { parser ->

it seems the plugin wants to parse the output of direnv export json. And apparently that used to work some while ago - direnv/direnv#467 . However if I try to manually run that command in the workdir containing .envrc the command succeeds but I get no output whatsoever (direnv allow . or not does not matter). So on first sight it appears that all the issues with intellij-direnv not doing anything come from the fact that direnv api has changed (or is not working as expected)? Does anyone know something about this? The command is still available tho https://github.com/direnv/direnv/blob/master/cmd_export.go

@fiksn
Copy link

fiksn commented Jun 26, 2021

Low hanging fruit theory - that direnv somehow changed the API which broke the integration can be dismissed I guess (see related issue).

My next theory / question is regarding https://github.com/fehnomenal/intellij-direnv/blob/master/src/main/kotlin/systems/fehn/intellijdirenv/services/EnvironmentService.kt. Ok, I can see how you change response of System.getenv() with some reflection. But I wonder how does that even work? I mean some other part could directly call functions to get environment variables and be totally unaffected by this or am I mistaken?

@phorsuedzie
Copy link

Workaround for a single project (i.e. without this plugin): start GoLand from the terminal, which then has all environment from direnv already loaded:

For macos, this is

open -a goland

@Chrisimx
Copy link

I investigated this issue. The process.waitFor() != 0 doesn't work anymore as direnv only terminates after its output has been read (but the direnv output seems correct). So the stdout first has to be read until EOF and then you could wait for termination of the proccess with a sane timeout, so that the IDE does not hang forever (as it does right now). I'm going to submit PR to fix the issue in the near future.

@Chrisimx Chrisimx linked a pull request Jan 10, 2025 that will close this issue
@Chrisimx
Copy link

Chrisimx commented Jan 10, 2025

I've now created a PR (#67) with the fix. I also provided the plugin built as ZIP there if you want to try it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants