buf-gradle-plugin icon indicating copy to clipboard operation
buf-gradle-plugin copied to clipboard

Symlink creation fails for non-privileged Windows user

Open denyska opened this issue 2 years ago • 5 comments

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.

denyska avatar Dec 07 '22 21:12 denyska

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?

andrewparmet avatar Dec 09 '22 07:12 andrewparmet

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

denyska avatar Dec 28 '22 09:12 denyska

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.

manuelgr0 avatar Sep 01 '23 14:09 manuelgr0

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.

andrewparmet avatar Sep 01 '23 14:09 andrewparmet

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).

gervaisj avatar Sep 27 '24 19:09 gervaisj