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

when attempting to load a lockfile and finding only a manifest, automatically generate a lockfile and load that #1980

Merged
merged 7 commits into from
Sep 6, 2024

Conversation

toph-allen
Copy link
Contributor

This pull request changes the behavior of renv_lockfile_load(), which attempts to load a lockfile from a directory. When no lockfile is found, but a manifest.json is found, the manifest is used to automatically generate a lockfile, which is then loaded. The behavior only occurs when the function is called with strict = FALSE, the default. If no manifest is present, the function renv_lockfile_init() is called, as before. A message is printed when this happens.

I added a supporting function in paths.R to return a manifest path, just cribbing from renv_paths_lockfile(). However, just doing file.path(project, "manifest.json") might be just as good. I'm not sure what the semantics are around path loading, so was just trying to follow existing patterns.

The logic in renv_manifest_path() is similar to renv_paths_lockfile(), or at least, the default case. I'm unsure about needing to add an extra layer of abstraction similar to renv_lockfile_path() -> renv_paths_lockfile().

When testing, I saw a duplicated log line:

No lockfile found; creating from `manifest.json`.
- Lockfile written to "/private/var/folders/q7/1b7h_nx931q6mc70r3w8k_2c0000gp/T/RtmpsmRCq6/file62e9cace1/renv.lock".
- Lockfile written to "/private/var/folders/q7/1b7h_nx931q6mc70r3w8k_2c0000gp/T/RtmpsmRCq6/file62e9cace1/renv.lock".

This came from explicit logging in renv_lockfile_from_manifest(), which duplicated a log message within renv_lockfile_write(), so I removed the duplicated outer logging statement.

R/lockfile.R Outdated Show resolved Hide resolved
Copy link
Collaborator

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

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

Overall LGTM; main nits are around style + suggesting we don't need the extra function for finding the path to manifest.json

R/lockfile.R Outdated Show resolved Hide resolved
R/lockfile.R Outdated Show resolved Hide resolved
R/lockfile.R Outdated Show resolved Hide resolved
toph-allen and others added 2 commits September 6, 2024 13:43
Copy link
Collaborator

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

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

LGTM!

@kevinushey kevinushey merged commit cf90ae8 into main Sep 6, 2024
11 checks passed
@toph-allen
Copy link
Contributor Author

@kevinushey I forgot to update the NEWS.md — would you like me to make another PR with that change or are you fine handling it?

@kevinushey
Copy link
Collaborator

I'll take care of it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants