i keep getting their is no package called rmarkdown error

Error in loadNamespace(name) : there is no package called ‘rmarkdown’
Calls: :: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
This is what am trying to run.
Rscript -e "rmarkdown::render('Analysis.Rmd',
params = list(state = 'Arizona',
data = 'data/rawdata/applemobilitytrends-2022-04-12.csv'))"
i have installed and run the package(install.packages("rmarkdown') then library("rmarkdown') but i still get this error.
I also installed it in the ubuntu Linux system for windows as i thought that would work but i still keep getting that error.
i noticed it downloads my packages to separate temp files.
in RStudio, its downloaded to AppData\Local\Temp\RtmpIrBsaE\downloaded_packages
in my ubuntu terminal, its downloaded to ‘/tmp/RtmpQfjjRQ/downloaded_packages’

Does it work when run in RStudio or console?

Do you mean the packages

Can you create an RMarkdown document in RStudio and does it render? When you have a terminal session of R, does

library(rmarkdown)

throw an error?

yes. I was able to run an RMarkdown document and it knitted and everything. It only shows me this error as am trying to run it through a shell script using command bash run....... in the terminal

OK. Let me see if i can reproduce on my Ubuntu (I can do a simple file render on my Mac)

Were you able to render your file

Yes, but only in macOS, but away from Ubuntu, so I'll have to try this evening. I think it may be a path issue, but I'm not sure yet.