Skip to content

Commit

Permalink
Use rtools40 for R >= 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen authored and jimhester committed Apr 19, 2020
1 parent 3168e24 commit 4d14c61
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions setup-r/action.yml
Expand Up @@ -6,8 +6,8 @@ inputs:
description: 'Version range or exact version of an R version to use.'
default: '3.x'
rtools-version:
description: 'Exact version of Rtools to use.'
default: '35'
description: 'Exact version of Rtools to use. Default uses latest suitable
rtools for the given version of R.'
Ncpus:
description: 'Value to set the R option `Ncpus` to.'
default: '1'
Expand Down
14 changes: 11 additions & 3 deletions setup-r/lib/installer.js
Expand Up @@ -290,8 +290,10 @@ function acquireRWindows(version) {
}
function acquireRtools(version) {
return __awaiter(this, void 0, void 0, function* () {
let fileName = util.format("Rtools%s.exe", version);
const rtools4 = version.charAt(0) == '4';
let fileName = util.format(rtools4 ? "rtools%s-x86_64.exe" : "Rtools%s.exe", version);
let downloadUrl = util.format("http://cloud.r-project.org/bin/windows/Rtools/%s", fileName);
console.log(`Downloading ${downloadUrl}...`);
let downloadPath = null;
try {
downloadPath = yield tc.downloadTool(downloadUrl);
Expand All @@ -311,8 +313,14 @@ function acquireRtools(version) {
core.debug(error);
throw `Failed to install Rtools: ${error}`;
}
core.addPath(`C:\\Rtools\\bin`);
core.addPath(`C:\\Rtools\\mingw_64\\bin`);
if (rtools4) {
core.addPath(`C:\\rtools40\\mingw64\\bin`);
core.addPath(`C:\\rtools40\\usr\\bin`);
}
else {
core.addPath(`C:\\Rtools\\bin`);
core.addPath(`C:\\Rtools\\mingw_64\\bin`);
}
});
}
function acquireQpdfWindows() {
Expand Down
3 changes: 1 addition & 2 deletions setup-r/lib/setup-r.js
Expand Up @@ -24,8 +24,7 @@ function run() {
core.debug(`started action`);
let version = core.getInput("r-version");
core.debug(`got version ${version}`);
let rtoolsVersion = core.getInput("rtools-version");
core.debug(`got rtools-version ${rtoolsVersion}`);
let rtoolsVersion = core.getInput("rtools-version") || (version.charAt(0) == '3' ? '35' : '40');
yield installer_1.getR(version, rtoolsVersion);
const matchersPath = path.join(__dirname, "..", ".github");
console.log(`##[add-matcher]${path.join(matchersPath, "rcmdcheck.json")}`);
Expand Down
14 changes: 10 additions & 4 deletions setup-r/src/installer.ts
Expand Up @@ -275,11 +275,13 @@ async function acquireRWindows(version: string): Promise<string> {
}

async function acquireRtools(version: string) {
let fileName: string = util.format("Rtools%s.exe", version);
const rtools4 = version.charAt(0) == '4';
let fileName: string = util.format(rtools4 ? "rtools%s-x86_64.exe" : "Rtools%s.exe", version);
let downloadUrl: string = util.format(
"http://cloud.r-project.org/bin/windows/Rtools/%s",
fileName
);
console.log(`Downloading ${downloadUrl}...`);
let downloadPath: string | null = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
Expand All @@ -300,9 +302,13 @@ async function acquireRtools(version: string) {

throw `Failed to install Rtools: ${error}`;
}

core.addPath(`C:\\Rtools\\bin`);
core.addPath(`C:\\Rtools\\mingw_64\\bin`);
if(rtools4){
core.addPath(`C:\\rtools40\\usr\\bin`);
core.addPath(`C:\\rtools40\\mingw64\\bin`);
} else {
core.addPath(`C:\\Rtools\\bin`);
core.addPath(`C:\\Rtools\\mingw_64\\bin`);
}
}

async function acquireQpdfWindows() {
Expand Down
3 changes: 1 addition & 2 deletions setup-r/src/setup-r.ts
Expand Up @@ -7,8 +7,7 @@ async function run() {
core.debug(`started action`);
let version = core.getInput("r-version");
core.debug(`got version ${version}`);
let rtoolsVersion = core.getInput("rtools-version");
core.debug(`got rtools-version ${rtoolsVersion}`);
let rtoolsVersion = core.getInput("rtools-version") || (version.charAt(0) == '3' ? '35' : '40');

await getR(version, rtoolsVersion);

Expand Down

1 comment on commit 4d14c61

@lcolladotor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this commit @jeroen and Jim! ^^

I tried my own version at https://github.com/lcolladotor/actions/tree/support_win_rtools_40 and https://github.com/lcolladotor/actions/tree/support_win_rtools_40_edit_repo_config but failed :P I detailed this at https://community.rstudio.com/t/compiler-support-fo-c-14-features-on-windows/57284/6.

I don't write JS code, I was just trying to hack my way through it. Looking at your code I can see why I failed. Thanks!!!! ^^

Please sign in to comment.