[PROF-13273] Fix profiler causing Bundler::PermissionError
#5146
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes a regression introduced in #4999: In that PR we added a call to
Bundler.bin_pathbut did not realize that bundler not only returns the path BUT CRUCIALLY it makes sure the path exists by going as far as trying to create it if it doesn't.If the directory does not exist, and the application directory is read-only (or the app does not have enough permissions), the application will fail with:
Fixes #5137
Motivation:
Fix a regression introduced in #4999 that shipped in v2.23.0.
Change log entry
Yes. Fix profiler causing
Bundler::PermissionErrorAdditional Notes:
The bundler's
bin_pathmethod has had a similarbehavior/implementation for 15+ years:
So we should be fine in replicating its behavior + having a test that checks we're matching it.
Worst case, we get
CodeProvenanceslightly off, which compared to "broke the app", seems better.I've also added a
rescueto the method so hopefully we don't run into more surprises here.(Note that while we could've kept calling
Bundler.bin_path, wrapping it with therescue, this would still produce the side-effect of creating the folder and it seems weird to me to end up in this situation of "turning on the profiler causes bin/ to be created". This is why I chose to reimplement the behavior, minus folder creation)How to test the change?
I've updated the test coverage.
Furthermore, the repro mentioned in #5137 also works to show it's fixed: