Commit 4d31c9b0 authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

Check for existence of (custom) library locations, and create them, if needed.

parent ab3a3b74
- (Try to) automatically create R user library location, if it does not exist
- (Try to) automatically create custom R library locations, if they do not exist
- Workaround for invalid EDITOR variable set by Kate Terminal plugin (also fixed in recent kate)
- kate plugin related actions are now active whenever a script window is active (not only the corresponding tool window)
- TODO: support kate plugins in detached windows
......
......@@ -413,7 +413,6 @@ void RInterface::handleRequest (RBackendRequest* request) {
RCommandChain *chain = openSubcommandChain (runningCommand ());
issueCommand ("paste (R.version[c (\"major\", \"minor\")], collapse=\".\")\n", RCommand::GetStringVector | RCommand::App | RCommand::Sync, QString (), this, GET_R_VERSION, chain);
// issueCommand ("try({userdir<-path.expand(Sys.getenv(\"R_LIBS_USER\")); if(length(userdir)==1L && !file.exists(userdir)) dir.create(userdir) })\n", RCommand::App | RCommand::Sync, QString (), this, 0, chain);
// find out about standard library locations
issueCommand ("c(path.expand(Sys.getenv(\"R_LIBS_USER\")), .libPaths())\n", RCommand::GetStringVector | RCommand::App | RCommand::Sync, QString (), this, GET_LIB_PATHS, chain);
// start help server / determined help base url
......
......@@ -548,7 +548,23 @@ void RKSettingsModuleRPackages::rCommandDone (RCommand *command) {
QString RKSettingsModuleRPackages::libLocsCommand () {
RK_TRACE (SETTINGS);
QString command = ".libPaths (unique (c (";
// For additional library locations configured inside RKWard, try to create them, as needed.
// This is especially important for versioned dirs (which will not exist after upgrading R, for instance)
QString command;
if (!liblocs.isEmpty()) {
bool first = true;
command = "local({\naddpaths <- unique (c(";
QStringList ll = expandLibLocs(liblocs);
foreach (const QString& libloc, ll) {
if (first) first = false;
else command.append (", ");
command.append (RObject::rQuote (libloc));
}
command.append ("))\nlapply(addpaths, function(p) { if (!dir.exists(p)) try(dir.create(p, recursive=TRUE)) })\n})\n");
}
// For add library locations set "the R way", try to interfere as little as possible.
command.append(".libPaths (unique (c (");
bool first = true;
QStringList ll = libraryLocations ();
foreach (const QString& libloc, ll) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment