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

Error on formatting within /tmp #1334

Closed
Ganitzsh opened this issue Aug 12, 2022 · 2 comments
Closed

Error on formatting within /tmp #1334

Ganitzsh opened this issue Aug 12, 2022 · 2 comments

Comments

@Ganitzsh
Copy link

I am using nvim with null-ls setup with buf for formatting. It was working great up until a month ago or so, and it stopped.

I created this issue jose-elias-alvarez/null-ls.nvim#1002 but according to the author the issue is most likely on the buf side. Not saying it is, but I'm looking for an answer.

Here's the proto file to format, it's very basic and nothing fancy:

syntax = "proto3";

package straudio.v1;

message AudioChunk {
     string name = 1;

   bytes data = 2;
}

Here's the output of the command when run within nvim:

[DEBUG Fri Aug 12 08:51:04 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:346: spawning command "buf" at /Users/<me>/Dev/audio-streamer/protos/v1 with args { "format", "-w", "/tmp/null-ls_UQJFGT.proto" }
[TRACE Fri Aug 12 08:51:04 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:217: error output: Failure: failed to enumerate module files: open /private/tmp/.vnc-vncservice: permission denied

[TRACE Fri Aug 12 08:51:04 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:218: output: nil

As you can see, the error says:

[TRACE Fri Aug 12 08:51:04 2022] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:217: error output: Failure: failed to enumerate module files: open /private/tmp/.vnc-vncservice: permission denied

It works when I run buf directly on the file within it's source folder outside of /tmp

I have no idea why this file is being opened in the first place. I am suspecting a conflicting file name /tmp/null-ls_UQJFGT.proto causing buf to try and open something else?

I'm running macOS version 12.4 and nvim version 0.7.2

@amckinney
Copy link
Contributor

At first glance, the problem looks like a combination of both null-ls.nvim and buf. The null-ls.nvim plugin is clearly moving the file to a temporary directory (hence the { "format", "-w", "/tmp/null-ls_UQJFGT.proto" } args in the log). The null-ls.nvim implementation specifies a configuration for this behavior here. So the null-ls.nvim plugin is causing this behavior - you just don't have permission to read all of the files contained in the /tmp directory that null-ls.nvim is using.

With that said, this directory is triggering this error in buf. In short, buf will try to read all of the .proto files contained from a file reference - when a single file input is used (like /tmp/null-ls_UQJFGT.proto in your case), buf will ascend the directory tree until it finds a buf.yaml or buf.work.yaml so that it can find the root from which import statements should be resolved from. If neither file is found, buf will assume that the root is in the current working directory.

It's possible that buf is being executed somewhere within /private/tmp/...and it's unable to read all of the directories there to discover .proto sources (hence the permission denied error).


Ok, so that was a mouthful. Put simply, this is working as expected from buf's perspective. However, the null-ls.nvim implementation is using a huge workaround in absence of this feature request. If buf format was able to read from stdin, this problem would go away.

I'm going to close this out because #1035 really is the issue to track for this feature. Now that I see the severity of the situation, we can try and get a fix out sooner rather than later! Thanks for the report!

@Ganitzsh
Copy link
Author

Thank you very much!

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

No branches or pull requests

2 participants