rubygems / bundler

Manage your Ruby application's gem dependencies
https://bundler.io
MIT License
4.88k stars 2k forks source link

Build local bundler on a "thread-safe folder" #7669

Closed deivid-rodriguez closed 4 years ago

deivid-rodriguez commented 4 years ago

What was the end-user or developer problem that led to this PR?

Sometimes tests that gem build to local version of bundler fail.

What is your fix for the problem, implemented in this PR?

Some tests using system_gems :bundler run gem build bundler.gemspec to build a local version of the bundler gem and install that to the temporary gem location for tests. After the test finishes, it removes the bundler*.gem artifact generated by gem build at the root of the repo.

The problem is that if two tests like this run concurrently, they can run into race condtions because they use the same common folder (the root folder). For example, test1 generates the bundler*.gem file, test2 (re)generates the bundler*.gem file, test1 removes the file after it's done, test2 fails to remove the file because it was already removed by other test.

To fix this issue, we generate this artifact on a "thread specific" folder, so it doesn't interfere with other threads.