I presume you're running:
install.packages("BH")
Does this work for you in R, but not in RStudio? (see FAQ below for disambiguation)