Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8247679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:55:49+00:00 2026-06-07T22:55:49+00:00

I asked this question earlier, but am still unable to get it working. I

  • 0

I asked this question earlier, but am still unable to get it working. I am trying to install custom packages upon starting R. A lot of the code that is written by us right now is available for editing to the users. To try and protect the code, I am packaging the production level code and having the users install it on their machine during start up.

However, when I try to install packages in RProfile.site file, the program goes into a loop and R is constantly launched over and over. I noticed that a lock file for the package is created along with the package in the library folder within R.

Here is the code I have added to the site file:

if(length(grep("customPackage", installed.packages()[,1]))==0) { 
        install.packages("customPackage", repos=NULL, type="source") 
} 

When I try to run this code after starting R (without changing the site file), it installs the package perfectly fine and moves on. However, when I try to do it through the RProfile file, that’s when it creates the problems.

Last time I tried resolving this issue (https://stackoverflow.com/questions/10610067/installing-packages-upon-starting-r-session), I thought Justin’s suggestion of using the if statement check for packages would fix the problem. But this only seems to solve the problem for packages I install from CRAN and not custom packages.

Any help on this matter would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:55:51+00:00Added an answer on June 7, 2026 at 10:55 pm

    I don’t understand why you’d want to do this. Just have them point their .libPaths to the same place. i.e. instead of install.packages(...), just add a line in Rprofile.site that says

    .libPaths('/path/to/common/libraries')
    require("commonPackage")
    

    Another thing that you might be able to do is make a system call. I don’t know much about installing packages under Windows, but on Unix-alike, instead of using install.packages you could do something like this:

    system("R --vanilla CMD INSTALL customPackage")
    

    Among other things, the --vanilla flag causes R to be started without using the Rprofile.site file (Your problem is that the Rprofile.site file is being read when R starts, but the Rprofile.site file tells R to install a package which requires starting R, which in turns reads your Rprofile.site file… etc.). Presumably, R --no-site-file INSTALL customPackage would also work.

    Edit

    After consulting this SO answer, it looks like you could do something like this on Windows (assuming you have installed Rtools), although I haven’t tested it.

    system("Rcmd --vanilla INSTALL customPackage")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked this question earlier: How to get delta between two text items But
I know that this question was asked earlier but the OP didn't get any
I asked a question earlier on this same project but I'm still having issues
I asked a question about this earlier but received no responses, so I'm trying
This question maybe asked earlier (atleast topic wise) , but still I couldn't find
I asked this question earlier. I am intrigued by std::set but I have another
I asked another version of this question on the gamedev.SE site earlier today but
This question was asked earlier by someone else but never answered: MKAnnotation - Map
I asked this question earlier and am now trying to explore the idea of
I asked this question earlier, but it got a negative vote, so I'm rewording

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.