Anyone managed to run Gradle in claude <sandboxed>...
# community-support
m
Anyone managed to run Gradle in claude sandboxed mode? I can make an exception for
~/.gradle
but I haven't found a way to allow the daemon to access the unix socket and I get things like this:
Copy code
Sandbox networking is blocking Gradle's file-lock socket. Retrying without the sandbox.
v
Maybe move to or post a link to here in #C0BQK6SC4LT? See also blog.gradle.org/gradle-is-going-agentic and github.com/gradle/build-tool-roadmap/issues/126
a
It can be tricky, I think
Copy code
network": {
      "allowLocalBinding": true
}
should allow it (note Gradle doesn't use unix domain sockets (yet?))
m
@Vampire right, forgot this existed, I'll crosspost there
@Anze Sodja thanks! TIL, I assumed from the message it was a Unix socket but I must say I'm not 100% sure
Copy code
Caused by: java.net.SocketException: Operation not permitted
   at java.base/sun.nio.ch.Net.bind0(Native Method)
   at java.base/sun.nio.ch.Net.bind(Net.java:525)
   at java.base/sun.nio.ch.DatagramChannelImpl.bindInternal(DatagramChannelImpl.java:1241)
   at java.base/sun.nio.ch.DatagramChannelImpl.bind(DatagramChannelImpl.java:1215)
   at java.base/sun.nio.ch.DatagramSocketAdaptor.bind(DatagramSocketAdaptor.java:106)
   at java.base/java.net.DatagramSocket.createDelegate(DatagramSocket.java:1311)
   at java.base/java.net.DatagramSocket.<init>(DatagramSocket.java:310)
   at java.base/java.net.DatagramSocket.<init>(DatagramSocket.java:349)
   at org.gradle.cache.internal.locklistener.DefaultFileLockCommunicator.<init>(DefaultFileLockCommunicator.java:45)
   ... 59 more
Copy code
"allowLocalBinding": true
this made the trick 👍
It's a bit over-allowing but I think it's fine for me
Would be nice to be able to whitelist exactly what Gradle is using
a
Would be nice to be able to whitelist exactly what Gradle is using
Definitely some guide would be nice Note that I also had problems with temp files, so something like this could help:
Copy code
"filesystem": {
      "allowWrite": [
        "/tmp",
        "/var/folders/*/*/T/**",
        "/private/var/folders/*/*/T/**",
      ]
}
👍 1
m
Yea, I'm stuck on
~/.konan
now
Copy code
.konan/kotlin-native-prebuilt-macos-aarch64-2.4.10/.lock
Apparently using
flock
which it isn't 100% clear if it can be bypassed from settings or not
a
"allowWrite": ["~/.konan"] 🙈
m
Tried that already 😄
This is what I got:
Copy code
The sandbox on macOS is enforced at the syscall level (via sandbox-exec/Seatbelt), not as a simple path-based ACL. A directory being in the write-allow list only guarantees plain open()/write() calls succeed there. Operations like creating a lock file with exclusive-create semantics, or flock()/fcntl(F_SETLK) calls, go through separate syscall filters that can be denied independently of general file-write permission.
No idea if this is real or hallucination ^^
I think for now I'll go the docker route
a
Maybe it's better. There you may get some other problems. E.g. if you want to share cache you may need to do some work
m
Yea
Also looking into hooks: code.claude.com/docs/en/hooks
That sounds promising but ... not sure yet
a
Yea, I'm stuck on ~/.konan now
@Martin Please make a YT issue for this, or anything related to KGP 🙏
a
I don't know how AI sandboxing works but you can override the location of
~/.konan
by setting
KONAN_DATA_DIR
env var. Maybe it's possible to set
KONAN_DATA_DIR
for Claude so it has its own location? Though it would be expensive in terms of disk space.
m
Yea by default only the current project dir is allowed. I think it makes sense to allow shared caches (
.gradle
,
.konan
, etc...)