0

Am trying to launch a shiny app using the below command.

Rscript -e "shiny::runApp('test-app', launch.browser=TRUE)"

However, I get an error as shown below

Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
  namespace 'htmltools' 0.4.0 is being loaded, but >= 0.4.0.9003 is required
Calls: :: ... getNamespace -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted

I did check my library folder and see that htmltools package is present.

I also tried the below dependencies=TRUE

install.packages(pkgs,lib = "C:/Users/User/Desktop/data/library",repo = "https://cloud.r-project.org",dependencies=TRUE)

Here pkgs is a list containing list of packages that has to be installed.

The problem is same script works in my system but it doesn't work in my colleague's system. How can I resolve this?

Can help me understand what's the issue?

Phil
  • 7,287
  • 3
  • 36
  • 66
The Great
  • 7,215
  • 7
  • 40
  • 128
  • Update the htmltools package ... – Roland Aug 06 '20 at 07:31
  • I tried `install.packages('htmltools')` but it still throws the same error – The Great Aug 06 '20 at 07:37
  • @Roland - I thought running `install.packages('htmltools') will always fetch the latest package – The Great Aug 06 '20 at 07:38
  • When I type `update.packages()` and try to launch the Shiny app, I also get the same error – The Great Aug 06 '20 at 07:45
  • The current version is 0.5.0. The error clearly says that your version is too old. – Roland Aug 06 '20 at 07:50
  • Yes, but my question is why is that `update.packages` or` install.packages('htmltools') `doesn't update/intsall the latest one... Aren't those the right commands? – The Great Aug 06 '20 at 07:54
  • How about an old and clean disinstall and reinstall? You may have `htmltools` installed in more than one folder (`path.package("htmltools")` to see where R reads it). With the command `.libPaths()` you should see all the possibles places where R saves its libraries. That package may be saved with different versions in more than one folder. – Edo Aug 06 '20 at 07:56
  • @Edo - What does it mean when `path.package("htmltools")` returns error like `none of the packages are loaded` – The Great Aug 06 '20 at 08:05
  • Actually I have installed this packages in a specific directory which is not in my `libpaths`... – The Great Aug 06 '20 at 08:07
  • First, you need to load the package: `library(htmltools)`. `path.package` will show you where R is reading it from. – Edo Aug 06 '20 at 08:07
  • How can I make R look at my package from a specific directory (which isn't in my libpaths). – The Great Aug 06 '20 at 08:08
  • The directory that I provided above in my post (`lib.loc`) isn't the libpaths – The Great Aug 06 '20 at 08:09
  • I guess the issue will be resolved the code looks up at my specific directory...instead of usual libpath. Can you let me know how can it be done? Though I have configured the path in `install.packages` and `update.packages`, the path.package still shows the `libpath` – The Great Aug 06 '20 at 08:11
  • Restart R [ctrl + shift + f10] then run `library(htmltools, lib.loc = "C:/Users/User/Desktop/data/library")`. Check the version with `packageVersion("htmltools")` – Edo Aug 06 '20 at 08:15
  • however, it's not a clean and shareable solution with your colleagues, because they will have to update your code every time they use it. I'd strongly suggest you to use the R default libraries locations. Or you could add that folder as a possible libpaths [again, I don't suggest that].. – Edo Aug 06 '20 at 08:20
  • Hi one quick question. Yes, it was showing 0.4.0... So I deleted it... And download R binaries (zip folder) version 0.5.0 and replaced it...When I type the command `packageVersion("htmltools")`, it still displays the old version which 0.4.0 – The Great Aug 06 '20 at 08:31
  • Restart R [ctrl + shift + f10] – Edo Aug 06 '20 at 08:32

2 Answers2

8

Although Kouadio has the correct answer, I found it difficult to follow those brief instructions, so I'm making them more detailed here.

  1. Quit RStudio.
  2. Find the RStudio launch icon, either on your desktop or in your Windows Start Menu.
  3. Right-click the icon and choose "Run as administrator." Say yes when prompted that this is really what you want to do.
  4. In RStudio, go to the Tools menu and choose Check for Updates.
  5. Select all the packages and choose to update them. Say yes to the relevant prompts.

You should then be able to use the Knit button again, but you probably want to quit RStudio and restart in non-administrative mode before doing so.

Nathan
  • 1,451
  • 1
  • 15
  • 28
2

I found new solution , you need to run rstudio with admin mode for check you update After all packages are installed Close Rstudio Run Rstudio in normal mode .

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    Yes, it worked. I just did it now. close your **Rstudio**, then run it as admin. Update or install all needed packages. Now run **Rstudio** normally and knit, all html, word and pdf will build perfectly. – Seyi May 19 '21 at 22:56