Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for renv profiles in setup-r to retrieve R version from renv.lock file #951

Open
LDSamson opened this issue Nov 22, 2024 · 1 comment
Labels
feature a feature request or enhancement help wanted ❤️ we'd love your help!

Comments

@LDSamson
Copy link

LDSamson commented Nov 22, 2024

When using renv profiles, it would be great if we can retrieve the R version from one of the profiles' renv.lock files with the setup-r action. Currently I need to hardcode the R version. There is an renv argument in the workflow but it does not take into account renv profiles since it only looks in the package directory for the renv.lock file and not in the renv folder:

if (version === "renv") {
let renv_lock_path = path.join(workingDirectory, "renv.lock");
if (fs.existsSync(renv_lock_path)) {
let renv_lock = fs.readFileSync(renv_lock_path).toString();
version = JSON.parse(renv_lock).R.Version;
core.debug(
`got version ${version} from renv.lock in ${workingDirectory}`,
);
} else {
core.setFailed(`renv.lock does not exist in ${workingDirectory}.`);
}
} else {
version = version;
core.debug(`got version ${version} from input`);
}

An example of the lock files' location when using renv profiles: renv folder, for example like this:

renv
├── activate.R
├── profile
├── profiles
│   ├── full
│   │   ├── renv
│   │   │   ├── settings.json
│   │   │   └── staging
│   │   └── renv.lock
│   └── minimal
│       ├── renv
│       │   ├── settings.json
│       │   └── staging
│       └── renv.lock
└── staging
@LDSamson LDSamson added the feature a feature request or enhancement label Nov 22, 2024
@gaborcsardi gaborcsardi added the help wanted ❤️ we'd love your help! label Nov 22, 2024
@gaborcsardi
Copy link
Member

A PR is welcome for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement help wanted ❤️ we'd love your help!
Projects
None yet
Development

No branches or pull requests

2 participants