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

Symlink creation fails for non-privileged Windows user #106

Open
denyska opened this issue Dec 7, 2022 · 5 comments
Open

Symlink creation fails for non-privileged Windows user #106

denyska opened this issue Dec 7, 2022 · 5 comments

Comments

@denyska
Copy link

denyska commented Dec 7, 2022

Plugin version: 0.8.2

Execution failed for task ':<REDACTED_PATH>:createSymLinksToModules'.
> java.nio.file.FileSystemException: c:\<REDACTED_PATH>\proto\build\bufbuild\src-main-proto: A required privilege is not held by the client

I guess something similar to https://github.com/golang/dep/pull/781/files#diff-ef03141dd8338143c09a5b30ceb3d079d25015a96f8b5292ee29daa23348df2e needs to be done, i.e. wrap symlink creation in try/catch and if failed and $os == windows then fallback to copying extracted and included proto dependencies.

Quick search reveals that this is only case for non-privileged Windows users, and admin user will be able to create symlinks without issues.

@andrewparmet
Copy link
Collaborator

I'm hesitant to bring back that old code path (before symlinks, this plugin did copy dependencies into one directory).

If two modules declare the same file then we'd have to decide who wins, and it's also not clear to me that there's a good way to catch those conflicts using the standard Gradle Copy task machinery. Using symlinks allows Buf to deal with that conflict resolution (i.e., it fails the build).

Is it not possible to run the build with the right permissions?

@denyska
Copy link
Author

denyska commented Dec 28, 2022

Is it not possible to run the build with the right permissions?

Unfortunately no.

As workaround, I’ve injected task that re-creates entire folder structure before CreateSymLinksToModulesTask. The workaround relies on this check https://github.com/andrewparmet/buf-gradle-plugin/blob/55c64c738361a5b5be23a9a4181ecf85006a203d/src/main/kotlin/com/parmet/buf/gradle/ProtobufGradlePluginSupport.kt#L63

@manuelgr0
Copy link

Hi
When trying to setup the buf gradle plugin v0.8.6 I still get some problems.

    id("com.google.protobuf") version "0.9.2"
    id("build.buf") version "0.8.6"

The gradle build just runs through and is okay, but the linting does not happen at all.

    id("com.google.protobuf") version "0.9.1"
    id("build.buf") version "0.8.6"

When using version 0.9.1 of the google protobuf plugin, the plugin seems to work but I run into the following issue:

Execution failed for task ':portfolio:createSymLinksToModules'.
> java.nio.file.FileSystemException

Is there any fix to this problem? I am running it on Windows as a non-privileged user.

@andrewparmet
Copy link
Collaborator

As of plugin version 0.8.5 you must use the protobuf-gradle-plugin version 0.9.2 or higher.

Can you provide a minimal reproducer for the first configuration that doesn't lint?

Note that you need to have the privilege to create symlinks.

@gervaisj
Copy link

On my side, as pointed out in this StackOverflow comment, I've enabled Developer Mode on my Windows machine and now the Buf plugin works as-is, no task injection required.

Note that one has to use JDK 13 at least for this work (see JDK-8218418).

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

4 participants