Search code examples
f#monogachomebrewsudo

How to write a brew formula if the installation require sudo?


I would like to write a brew formula but it looks like my library, which registers in Mono's GAC, would require sudo rights. which goes against brew idea of not sudoing.

Is there a work around ?

gacutil -i /private/tmp/fsharp-qdRr/fsharp-3.0.24/lib/release/4.0/FSharp.Core.dll -root /Library/Frameworks/Mono.framework/Versions/3.0.1/lib/ -package 4.0
gacutil -i /private/tmp/fsharp-qdRr/fsharp-3.0.24/lib/release/2.1/FSharp.Core.dll -root /Library/Frameworks/Mono.framework/Versions/3.0.1/lib/ -package 2.1
gacutil -i /private/tmp/fsharp-qdRr/fsharp-3.0.24/lib/release/2.0/FSharp.Core.dll -root /Library/Frameworks/Mono.framework/Versions/3.0.1/lib/ -package 2.0
Failure adding assembly /private/tmp/fsharp-qdRr/fsharp-3.0.24/lib/release/2.0/FSharp.Core.dll to the cache: gac directories could not be created, possibly permission issues.
Failure adding assembly /private/tmp/fsharp-qdRr/fsharp-3.0.24/lib/release/4.0/FSharp.Core.dll to the cache: gac directories could not be created, possibly permission issues.
Failure adding assembly /private/tmp/fsharp-qdRr/fsharp-3.0.24/lib/release/2.1/FSharp.Core.dll to the cache: gac directories could not be created, possibly permission issues.make[2]: *** [install-lib-4] Error 1

and the dir mentioned as installation point is owned by the root user

➜   pwd
/Library/Frameworks/Mono.framework/Versions/3.0.1/lib
➜   ls -ld .
drwxr-xr-x  324 root  admin  11016 Dec  1 17:41 .

Solution

  • Mono allows you to have multiple GAC folders -- this way you can keep a per-user GAC (in some folder that you have write/execute privileges) and a system-wide GAC. Whenever an assembly is loaded from the GAC, it'll search the user's GAC first, then fall back to the system-wide GAC if necessary.