When you’re getting a No such file or directory, but the file is there and ldd suggests the libraries can be resolved as well, I suspect it’s the interpreter that’s missing. You can check with patchelf --print-interpreter /home/myuser/.nuget/packages/grpc.tools/2.36.4/tools/linux_x64/protoc: I suspect it might be pointing to something like /lib64.
You could use patchelf to set the interpreter to the location where it is in nixpkgs, with something like patchelf --set-interpreter $(< "$NIX_CC/nix-support/dynamic-linker") /home/myuser/.nuget/packages/grpc.tools/2.36.4/tools/linux_x64/protoc.
However, when protoc is ‘managed’ by nuget, this is kinda inconvenient. In such cases, I usually run the build inside a shell.nix using buildFHSUserEnv:
As you say, it’s a bit annoying as it’s managed by Nuget.
I’ll try your workaround as I never seen this (I need to read documentation about buildFHSUserEnv to understand it, I imagine the targetPkgs are the lib needed to build your project? All of them?). Will it mean I will need to manually build from the command line before launching my favorite IDE (like rider) ?
Also I don’t seem to have a $NIX_CC in my env:
[myuser@home:~]$ patchelf --set-interpreter $(< "$NIX_CC/nix-support/dynamic-linker") /home/myuser/.nuget/packages/grpc.tools/2.36.4/tools/linux_x64/protoc
bash: /nix-support/dynamic-linker: No such file or directory
patchelf: missing filename
[myuser@home:~]$ echo $NIX_CC