The solution below will work for unix-like operating systems including Mac OS X.
First, we need a location to install all our packages from now on. This can be any directory, and location of this directory should be indicated in ~/.Renviron file. Let's create that directory now:
We created Rlibs directory in our home directory. Now, create the .Renviron file in your home directory and enter the following line and save the .Renviron file:
We can now start R and install any library. The libraries will be installed to ~/Rlibs, and when we update R, R will still look for libraries in ~/Rlibs directory so we don't need to re-install the libraries. However, we will need to update the libraries in ~/Rlibs directory to their most recent versions. All we need to do is to run update.packages() in R console, and the libraries will be updated.
You can also update Bioconductor package as follows (this probably works with newer versions of Bioconductor):
see here for setting environment variables in Windows