Installation issue on Mac

Hello, I am trying to install igraph in R via terminal by typing “install.packages(“igraph”, type = “source”)”. I am using MacBook Air Ventura 13.0, and I just install R latest version (4.4.2_2). But I get the error below:

Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/homebrew/lib/R/4.4/site-library/00LOCK-igraph/00new/igraph/libs/igraph.so':
  dlopen(/opt/homebrew/lib/R/4.4/site-library/00LOCK-igraph/00new/igraph/libs/igraph.so, 0x0006): Library not loaded: @rpath/libc++.1.dylib
  Referenced from: <2752C6BE-86AB-33C1-9163-94303AC7981F> /opt/homebrew/lib/R/4.4/site-library/00LOCK-igraph/00new/igraph/libs/igraph.so
  Reason: tried: '/System/Volumes/Preboot/Cryptexes/OS@rpath/libc++.1.dylib' (no such file), '/opt/homebrew/Cellar/r/4.4.2_2/lib/R/lib/libc++.1.dylib' (no such file)
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/opt/homebrew/lib/R/4.4/site-library/igraph’

The downloaded source packages are in
	‘/private/var/folders/jd/8k7kg6v10sq4pnlc83zxy8wh0000gn/T/RtmpTPubzw/downloaded_packages’
Warning message:
In install.packages("igraph", type = "source") :
  installation of package ‘igraph’ had non-zero exit status

I’m not sure what’s going wrong. If libc++ is not accessible, your configuration may be broken.

What I can say is that I do not recommend installing R with Homebrew. This will force you to compile all R packages from sources. Install R from CRAN: it will save you a lot of trouble, it’ll be more compatible in general, and you will gain access to pre-compiled packages from CRAN.

If you are not comfortable compiling software from sources and resolving the issues that come with it, then using Homebrew’s R is not a good idea.