brew update実行時に、Permission deniedになる場合の対処方法


# 問題

```
% brew update        
```


出力結果

```
error: unable to unlink old 'Library/ENV/scm/git' (Permission denied)
error: unable to unlink old 'Library/Homebrew/manpages/brew.1.md' (Permission denied)
Error: Failure while executing: git pull --ff --no-rebase --quiet origin refs/heads/master:refs/remotes/origin/master
```

# 解決方法

```
$ sudo chown -R `whoami` /usr/local
$ cd /usr/local
$ git reset --hard origin/master
```

## 再実行


```
% brew update        
```

出力結果

```
==> New Formulae
homebrew/binary/chronograf                                       homebrew/science/minimap                                         homebrew/versions/antlr3                                       
homebrew/binary/rebol-core                                       homebrew/science/msieve                                          homebrew/versions/apache-spark131                              
homebrew/binary/rebol-view                                       homebrew/science/multi-worm-tracker                              homebrew/versions/apache-spark141                              
homebrew/science/abacas                                          homebrew/science/ncbi-c++-toolkit                                homebrew/versions/astyle204                                    
homebrew/science/ace-corrector                                   homebrew/science/nccmp                                           homebrew/versions/boot2docker162                               
homebrew/science/andi                                            homebrew/science/nip2                                            homebrew/versions/docker162                                    
homebrew/science/arrayfire                                       homebrew/science/opencv3                                         homebrew/versions/docker171                                    
homebrew/science/art                                             homebrew/science/oswitch                                         homebrew/versions/elasticsearch17                              
homebrew/science/ascii_plots                                     homebrew/science/pathd8                                          homebrew/versions/erlang-r17                                   
homebrew/science/astral                                          homebrew/science/paxtools                                        homebrew/versions/freetds091                                   
homebrew/science/bcalm                                           homebrew/science/phipack                                         homebrew/versions/gdal111                                      
homebrew/science/bioformats-cpp                                  homebrew/science/phyutility                                      homebrew/versions/gegl02                                       
homebrew/science/biointerchange                                  homebrew/science/pilercr                                         homebrew/versions/go14                                         
homebrew/science/biopp                                           homebrew/science/pilon                                           homebrew/versions/gradle24                                     
homebrew/science/blaze-lib                                       homebrew/science/poretools                                       homebrew/versions/gradle26                                     
homebrew/science/boost-compute                                   homebrew/science/psmc                                            homebrew/versions/gradle27                                     
homebrew/science/circlator                                       homebrew/science/quest                                           homebrew/versions/gradle28                                     
homebrew/science/clinfo                                          homebrew/science/r8s                                             homebrew/versions/influxdb08                                   
homebrew/science/cmdstan                                         homebrew/science/rna-star                                        homebrew/versions/iojs                                         
homebrew/science/cryptoverif                                     homebrew/science/rnammer                                         homebrew/versions/jruby168                                     
homebrew/science/datamash                                        homebrew/science/simulate-pcr                                    homebrew/versions/jruby1721                                    
homebrew/science/dazz_db                                         homebrew/science/sortmerna                                       homebrew/versions/jruby9000                                    
homebrew/science/dextractor                                      homebrew/science/spici                                           homebrew/versions/jython253                                    
homebrew/science/dida                                            homebrew/science/suite-sparse421                                 homebrew/versions/libxc21                                      
homebrew/science/ea-utils                                        homebrew/science/superlu43                                       homebrew/versions/libxml278                                    
homebrew/science/exabayes                                        homebrew/science/transdecoder                                    homebrew/versions/lz4r117                                      
homebrew/science/gap                                             homebrew/science/transpose                                       homebrew/versions/mapnik2                                      
homebrew/science/graphlan                                        homebrew/science/transrate-tools                                 homebrew/versions/mysql56                                      
homebrew/science/gubbins                                         homebrew/science/ucto                                            homebrew/versions/nasm21106                                    
homebrew/science/hisat2                                          homebrew/science/vcflib                                          homebrew/versions/nifi021                                      
homebrew/science/humann2                                         homebrew/science/vips7                                           homebrew/versions/node012                                      
homebrew/science/iva                                             homebrew/science/vsearch                                         homebrew/versions/node4-lts                                    
homebrew/science/libcerf                                         homebrew/science/wfdb                                            homebrew/versions/protobuf260                                  
homebrew/science/libfolia                                        homebrew/science/xcdf                                            homebrew/versions/saxon6                                       
homebrew/science/mash                                            homebrew/science/yass                                            homebrew/versions/selenium-server-standalone245                
homebrew/science/metaphlan                                       homebrew/versions/android-ndk-r10d                               homebrew/versions/zeromq405                                    
homebrew/science/minced                                          homebrew/versions/ansible18                                    
==> Updated Formulae
homebrew/binary/adobe-air-sdk                   homebrew/science/gmsh                           homebrew/science/p4est                          homebrew/science/veclibfort                   
homebrew/binary/adobe-air-sdk-flex              homebrew/science/gmt                            homebrew/science/parmetis                       homebrew/science/vips                         
homebrew/binary/ddptools                        homebrew/science/gmt4                           homebrew/science/pastix                         homebrew/science/vislcg3                      
homebrew/binary/eventstore                      homebrew/science/gnudatalanguage                homebrew/science/pathvisio                      homebrew/science/vtk                          
homebrew/binary/mpress                          homebrew/science/grabix                         homebrew/science/petsc                          homebrew/science/vtk5                         
homebrew/binary/perforce                        homebrew/science/graph-tool                     homebrew/science/piler                          homebrew/science/wcslib                       
homebrew/binary/perforce-proxy                  homebrew/science/gromacs                        homebrew/science/prank                          homebrew/science/wcstools                     
homebrew/binary/perforce-server                 homebrew/science/h5utils                        homebrew/science/prokka                         homebrew/science/wxmaxima                     
homebrew/binary/subgit                          homebrew/science/harvest-tools                  homebrew/science/proverif                       homebrew/science/xmgredit                     
homebrew/science/abinit                         homebrew/science/hdf5                           homebrew/science/pspp                           homebrew/science/xmi-msim                     
homebrew/science/abyss                          homebrew/science/healpix                        homebrew/science/pulseview                      homebrew/science/xrmc                         
homebrew/science/adam                           homebrew/science/hisat                          homebrew/science/pymol                          homebrew/science/yaggo                        
homebrew/science/alembic                        homebrew/science/hopdm                          homebrew/science/qr_mumps                       homebrew/science/yaha                         
homebrew/science/alpscore                       homebrew/science/htsbox                         homebrew/science/qrupdate                       homebrew/versions/bind99                      
homebrew/science/armadillo                      homebrew/science/hwloc                          homebrew/science/qualimap                       homebrew/versions/elasticsearch14             
homebrew/science/arpack                         homebrew/science/hypre                          homebrew/science/quast                          homebrew/versions/gcc49                       
homebrew/science/asl                            homebrew/science/igv                            homebrew/science/r                              homebrew/versions/gcc5                        
homebrew/science/astrometry-net                 homebrew/science/insighttoolkit                 homebrew/science/r-gui                          homebrew/versions/glfw3                       
homebrew/science/atomic-pseudopotential-engine  homebrew/science/inter-views                    homebrew/science/radx                           homebrew/versions/gnupg21                     
homebrew/science/bali-phy                       homebrew/science/ipopt                          homebrew/science/readseq                        homebrew/versions/gnutls34                    
homebrew/science/bam-readcount                  homebrew/science/kallisto                       homebrew/science/repeatmodeler                  homebrew/versions/hdf4                        
homebrew/science/bamtools                       homebrew/science/kent-tools                     homebrew/science/root                           homebrew/versions/jenkins-lts                 
homebrew/science/bamutil                        homebrew/science/lammps                         homebrew/science/root6                          homebrew/versions/jetty76                     
homebrew/science/barrnap                        homebrew/science/last                           homebrew/science/rstudio-server                 homebrew/versions/libmongoclient-legacy       
homebrew/science/bedtools                       homebrew/science/libmatio                       homebrew/science/sailfish                       homebrew/versions/libpng12                    
homebrew/science/bioawk                         homebrew/science/libpll                         homebrew/science/salmon                         homebrew/versions/llvm36                      
homebrew/science/biobloomtools                  homebrew/science/libsigrokdecode                homebrew/science/sambamba                       homebrew/versions/lua53                       
homebrew/science/blasr                          homebrew/science/lighter                        homebrew/science/samblaster                     homebrew/versions/mongodb26                   
homebrew/science/blast                          homebrew/science/links-scaffolder               homebrew/science/scalapack                      homebrew/versions/mysql55                     
homebrew/science/bowtie                         homebrew/science/lumpy-sv                       homebrew/science/seqdb                          homebrew/versions/nettle3                     
homebrew/science/bowtie2                        homebrew/science/madlib                         homebrew/science/sfscode                        homebrew/versions/node010                     
homebrew/science/bpipe                          homebrew/science/mathgl                         homebrew/science/slepc                          homebrew/versions/node08                      
homebrew/science/butterflow                     homebrew/science/maxima                         homebrew/science/snid                           homebrew/versions/openssl098                  
homebrew/science/cantera                        homebrew/science/mbsystem                       homebrew/science/snp_sites                      homebrew/versions/openssl101                  
homebrew/science/cd-hit                         homebrew/science/megahit                        homebrew/science/snpeff                         homebrew/versions/play13                      
homebrew/science/cdo                            homebrew/science/metis4                         homebrew/science/spades                         homebrew/versions/postgresql8                 
homebrew/science/cdsclient                      homebrew/science/mhap                           homebrew/science/sratoolkit                     homebrew/versions/postgresql9                 
homebrew/science/ceres-solver                   homebrew/science/mlst                           homebrew/science/statismo                       homebrew/versions/postgresql91                
homebrew/science/clustal-omega                  homebrew/science/mumps                          homebrew/science/stringtie                      homebrew/versions/postgresql92                
homebrew/science/daligner                       homebrew/science/nanopolish                     homebrew/science/suite-sparse                   homebrew/versions/postgresql93                
homebrew/science/dealii                         homebrew/science/ncview                         homebrew/science/sumo                           homebrew/versions/redis26                     
homebrew/science/dgtal                          homebrew/science/netcdf                         homebrew/science/sundials                       homebrew/versions/redis28                     
homebrew/science/diamond                        homebrew/science/neuron                         homebrew/science/superlu                        homebrew/versions/ruby187                     
homebrew/science/ds9                            homebrew/science/nextflow                       homebrew/science/superlu_dist                   homebrew/versions/ruby193                     
homebrew/science/dsk                            homebrew/science/nonpareil                      homebrew/science/swetest                        homebrew/versions/ruby20                      
homebrew/science/etsf_io                        homebrew/science/novoalign                      homebrew/science/swrcfit                        homebrew/versions/ruby21                      
homebrew/science/fermikit                       homebrew/science/octave                         homebrew/science/ticcutils                      homebrew/versions/tomcat6                     
homebrew/science/fgsl                           homebrew/science/openblas                       homebrew/science/timbl                          homebrew/versions/tomcat7                     
homebrew/science/flann                          homebrew/science/opencascade                    homebrew/science/tisean                         homebrew/versions/v8-315                      
homebrew/science/flint                          homebrew/science/opencv                         homebrew/science/trans-abyss                    peco/peco/peco (installed)                    
homebrew/science/fwdpp                          homebrew/science/openfst                        homebrew/science/trilinos                     
homebrew/science/genometools                    homebrew/science/openimageio                    homebrew/science/ucsc-genome-browser          
homebrew/science/getdp                          homebrew/science/osgearth                       homebrew/science/vcftools                     
==> Renamed Formulae
homebrew/science/gal-sim -> homebrew/science/galsim
==> Deleted Formulae
homebrew/binary/consul                                           homebrew/science/coinutils                                       homebrew/versions/allegro5                                     
homebrew/binary/exercism                                         homebrew/science/fast-statistical-alignment                      homebrew/versions/mapnik071                                    
homebrew/binary/packer                                           homebrew/science/z3                                              homebrew/versions/plowshare3                                   

```
# 

# 参考
https://github.com/Homebrew/homebrew/issues/2906