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

Remove Dir.chdir for thread-safety #397

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lovro-bikic
Copy link

Currently, Bundler::Audit::Database#update!, #commit_id and #last_updated_at fail in multi-threaded environments (like background processing jobs) because they use Dir.chdir.

From Ruby docs on Dir.chdir:

In a multi-threaded program an error is raised if a thread attempts to open a chdir block while another thread has one open, or a call to chdir without a block occurs inside a block passed to chdir (even in the same thread).

This PR removes the need for Dir.chdir by using Open3.capture2 from the stdlib with the chdir option.

External behavior should stay the same: Dir.chdir raises an Errno::ENOENT error given an non-existent directory, and the same holds with the new implementation.

Fixes #156

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.

Bundler audit is not thread safe
1 participant