Difficulty installing Rtools

I have been trying to install Rtools40 following the instructions on Cran-R project. I went through the first few steps including putting the location of Rtools on the path.
However, when I tried to install jsonlite:
install.packages("jsonlite", type = "source") it came up with this warning suggesting that Rtools hasn't been successfully installed. I'm quite confused!

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:


Installing package into ‘C:/Users/user/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/jsonlite_1.7.2.tar.gz'
Content type 'application/x-gzip' length 421716 bytes (411 KB)
downloaded 411 KB
  • installing source package 'jsonlite' ...
    ** package 'jsonlite' successfully unpacked and MD5 sums checked
    ** libs

*** arch - i386
c:/Rtools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-35~1.3/include" -DNDEBUG -Iyajl/api -D__USE_MINGW_ANSI_STDIO -O3 -Wall -std=gnu99 -mtune=generic -c base64.c -o base64.o
sh: c:/Rtools/mingw_32/bin/gcc: No such file or directory
make: *** [C:/PROGRA~1/R/R-35~1.3/etc/i386/Makeconf:208: base64.o] Error 127
ERROR: compilation failed for package 'jsonlite'

  • removing 'C:/Users/user/Documents/R/win-library/3.5/jsonlite'
  • restoring previous 'C:/Users/user/Documents/R/win-library/3.5/jsonlite'
    In R CMD INSTALL
    Warning in install.packages :
    installation of package ‘jsonlite’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\user\AppData\Local\Temp\RtmpSQKvdI\downloaded_packages’

RTools40 is for been used with R >= 4.0.0 for older R versions you have to download a suitable RTools version from here

Thank you so much! I have no idea how I didn't notice that. Very helpful