Skip to content

Commit

Permalink
rig rstudio: change order of arguments
Browse files Browse the repository at this point in the history
To work around an `open` bug.
Closes #208.
  • Loading branch information
gaborcsardi committed Apr 6, 2024
1 parent ac3d4cd commit 4f7a3fc
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,24 +801,30 @@ pub fn sc_rstudio_(version: Option<&str>,
-> Result<(), Box<dyn Error>> {

let cwd = std::env::current_dir();

let mut args = match project {
None => match cwd {
Ok(x) => osvec!["-n", "-a", "RStudio", "--args", x],
Err(_) => osvec!["-n", "-a", "RStudio"]
},
Some(p) => osvec!["-n", p],
// open -n -a RStudio
None => osvec!["-n", "-a", "RStudio"],
// open -n <project>
Some(p) => osvec!["-n", p]
};
let path;

// open ... --env RSTUDIO_WHICH_R=...
if let Some(ver) = version {
let ver = check_installed(&ver.to_string())?;
if !is_orthogonal(&ver)? {
bail!("R {} is not orthogonal, it cannot run as a non-default. \
Run `rig system make-orthogonal`.", ver)
}
path = "RSTUDIO_WHICH_R=".to_string() + R_ROOT + "/" + &ver + "/Resources/R";
let mut args2 = vec![os("--env"), os(&path)];
args.append(&mut args2);
let path = "RSTUDIO_WHICH_R=".to_string() + R_ROOT + "/" + &ver + "/Resources/R";
args.append(&mut osvec!["--env", &path]);
}

// add current directory if there is no project
if let None = project {
if let Ok(x) = cwd {
args.append(&mut osvec!["--args", x]);
}
}

if let Some(arg) = arg { args.push(arg.to_os_string()); }
Expand Down

0 comments on commit 4f7a3fc

Please sign in to comment.