Is there a method for a process (without root) to hide or mount over a path of the filesystem for itself? It shouldn't affect the actual filesystem, only the process itself and perhaps its children?Bit of an odd use case, but I need to build something on an OSX build server as if it were a vanilla OSX machine. However unfortunately there are a few libs installed in /usr/local/{include,lib} which mess up the build and I don't have root on the machine. So I would like to temporary hide /usr/local while running configure and make.I do not have write access to /usr/local so I cannot actually modify it.
Hide or mask directory for a process on OS-X
filesystems;mount;osx;fstab;chroot
No, there's no direct way to do this.  You can use chflags hidden to hide things from the Finder, but that doesn't affect the command-line.The solution would depend on the configure script.  It may simply look along PATH to notice the /usr/local, but more likely it will have a hardcoded list of directories to look at — including /usr/local.  To work around the former (PATH-based), you could adjust your path.  For the latter, the only thing that works is to modify the configure script.The reason why you'll see hardcoded lists is that add-ons may not use the same search paths as the rest of the system.  For instance, the various BSD ports may use /usr/pkg, /usr/local, etc., and partly rely upon the packagers to set these pathnames in their build-scripts.  But programs that are not built as part of the ports system have to look for things in those places, to build with little user attention.If you want to override the default search path for OSX, start with the ld manual page, which saysSearch pathsld maintains a list of directories to search for a library or framework  to use.  The default library search path is /usr/lib then /usr/local/lib.  The -L option will add a new library search path.  The default framework  search path is /Library/Frameworks then /System/Library/Frameworks.  (Note: previously, /Network/Library/Frameworks was at the end of the  default path.  If you need that functionality, you need to explicitly add  -F/Network/Library/Frameworks).  The -F option will add a new framework  search path.  The -Z option will remove the standard search paths.  The  -syslibroot option will prepend a prefix to all search paths.and you can pass options to ld by prefixing them with -Wl (and using a comma where a space is needed).  For your purpose, you would write a script whichuses -Z to remove the search paths, andadd back the parts you need using -LThe clang option -v shows the details of the compiler front-end, and passing -v to ld, e.g., using -Wl,-v shows the linker's details.Something like this, for example:#!/bin/shclang -Wl,-Z -L/usr/lib -F/Library/Frameworks -F/System/Library/Frameworks $@It is not documented in the clang manual, but a quick check shows that it would pass a plain -Z option to the linker.  On the other hand, clang does document options (mainly for gcc-compatibility) which suppress its searches of different categories of include-directories:   -nostdinc          Do not  search  the  standard  system  directories  or  compiler          builtin directories for include files.   -nostdlibinc          Do not search the standard system directories for include files,          but do search compiler builtin include directories.   -nobuiltininc          Do not search clang's builtin directory for include files.It does not have an option for showing the search-path for include files, but you can infer that by running the preprocessor.Once you've gotten the script working, then running the configure script, you would set CC to that script's name, e.g.,./configure CC=cc-systemI've been doing this a while, but haven't needed this particular combination (see Compiler wrappers).