skip to Main Content

I am using VS Code User Installer on my work laptop. This means everything is installed at the user level. Next, I followed the steps mentioned on the R Extension for Visual Studio Code to install support for R language.

  1. Install R (>= 3.4.0) on your system.
  2. install.packages("languageserver")
  3. Install the R extension for VS Code from the VS Code Extension Marketplace
  4. Create an R file and start coding.

Following step 2, when I tried to install "languageserver", it failed, giving me the following error messages.

> install.packages("languageserver")
Installing package into 'C:/Users/1229437/AppData/Local/R/win-library/4.3'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cran.wu.ac.at/bin/windows/contrib/4.3/languageserver_0.3.16.zip'
Content type 'application/zip' length 826432 bytes (807 KB)
downloaded 807 KB

package 'languageserver' successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package 'languageserver'
Warning: restored 'languageserver'

The downloaded binary packages are in
        C:Users1229437AppDataLocalTempRtmpOiMn77downloaded_packages
Warning message:
In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:Users1229437AppDataLocalRwin-library4.30LOCKlanguageserverlibsx64languageserver.dll
  to C:Users1229437AppDataLocalRwin-library4.3languageserverlibsx64languageserver.dll: Permission denied

It looks like the problem is with copying the required files to the R library folder. Maybe it is because I am logged in as a User on my work laptop and don’t have the proper permissions. What is the best way to get rid of this error other than buying and using a personal laptop 🙂

2

Answers


  1. Chosen as BEST ANSWER

    It seems that the issue was with VS Code itself. Whenever I tried to install certain packages using the R terminal within VS Code, I received a "permission denied" error. However, when I closed VS Code and used the R terminal that was installed with the language installer, the package installation was successful. After reopening VS Code, everything worked perfectly.


  2. There seems to be a (possibly broken) existing installation of languageserver that cannot be removed. Here are 3 things you can try:

    1.

    Run the command

    .libPaths()
    

    inspect each of the directories output by libpaths (if they exist). If any of these have a folder called ‘languageserver’, delete this folder after closing R/RStudio. Then try the installation again (best if R/RStudio is run as administrator during install).

    2.

    Since the problem is with a dll file, check that languageserver.dll is not loaded in the current session with

    getLoadedDLLs()
    

    before installing. If the dll is loaded try restarting the R session.

    3.

    Otherwise it might work to install to a custom directory you can edit (here c:/writeable/directory)

    install.packages("languageserver", lib="C:/Writeable/directory")
    

    For an ordinary package, it could now be run with

    library("languageserver", lib.loc="C:/Writeable/directory")
    

    but to work with Visual Studio, something like

    options(langserver_library = 'C:/Writeable/directory')
    

    must be appended to the .Rprofile file. The package languageserversetup can assist with this, specifically the function

    languageserver_add_to_rprofile(rlsLib=c("C:/Writeable/directory"))
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search