Skip to content

Commit

Permalink
add user library to .libPaths() when it is created
Browse files Browse the repository at this point in the history
  • Loading branch information
s-u committed Apr 18, 2022
1 parent 727fc3b commit 87b277c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion PackageInstaller.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,15 @@ - (IBAction)installSelected:(id)sender
SLog(@"PackageInstaller.installSelected: real location=%@", realLoc);
if (!realLoc || ![[NSFileManager defaultManager] fileExistsAtPath:realLoc]) {
if (realLoc && pkgInst==kUserLevel) { // create user-level path if it doesn't exist
system([[NSString stringWithFormat:@"mkdir -p %@", realLoc] UTF8String]);
NSError *err = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:realLoc withIntermediateDirectories:YES attributes:nil error:&err];
if(err != nil) {
[self busy: NO];
NSRunAlertPanel(NLS(@"Package Installer"),NLS(@"User library could not be created."),NLS(@"OK"),nil,nil);
return;
}
// we don't want to re-start R, so add it to .libPaths() since it would have been dropped on init
[[REngine mainEngine] evaluateString: [NSString stringWithFormat:@".libPaths(c(%@,.libPaths()))", targetLocation]];
} else {
[self busy: NO];
NSRunAlertPanel(NLS(@"Package Installer"),NLS(@"The installation location doesn't exist."),NLS(@"OK"),nil,nil);
Expand Down

0 comments on commit 87b277c

Please sign in to comment.