trouble installing devtools on AWS instance

i cannot install devtools on an AMI instance. Every time i run install.packages('devtools') i get this error message

Configuration failed to find libgit2 library. Try installing:
 * brew: libgit2 (MacOS)
 * deb: libgit2-dev (Debian, Ubuntu, etc)
 * rpm: libgit2-devel (Fedora, CentOS, RHEL)
If libgit2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libgit2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: git2.h: No such file or directory
compilation terminated.```

You are missing a system dependency (not an R package), depending on the OS you are runing in your virutal machine you have to choose one of this options to insall.

can i run this code in RStudio or do i need to run it in the bash terminal?

You need to install it in your system, not in R, so you have to use a system terminal.