Skip to content
Snippets Groups Projects
Commit 828beec5 authored by Stan Hu's avatar Stan Hu
Browse files

Ensure Ruby default gem directories are preserved in cache

Default gems such as `ruby2_keywords` create blank directories. For
example, `ruby2_keywords` in Ruby 3.2 creates:

```
root@build:/# ls -al /opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems/ruby2_keywords-0.0.5
total 8
drwxr-xr-x  2 root root 4096 Feb 22 23:22 .
drwxr-xr-x 89 root root 4096 Feb 22 23:22 ..
```

Omnibus uses a Git cache that runs `git add -A -f
--worktree=/opt/gitlab`.  Because these directories are blank, the
Omnibus Git cache doesn't preserve them.

This doesn't seem to cause problems because Bundler ultimately cares
whether the `.gemspec` file exists, but it is confusing. We should
preserve these directories as they were created by Ruby.

Fix this by adding a blank `.gitkeep` to all subdirectories inside
`/opt/gitlab/embedded/lib/ruby/gems/3.2.0/gems` for Ruby 3.2.

Relates to https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8935

Changelog: fixed
parent 0859036c
No related branches found
No related tags found
No related merge requests found
......@@ -180,4 +180,10 @@
# Install OpenSSL gem for FIPS fixes
gem "install openssl --version '#{Gitlab::Util.get_env('OPENSSL_GEM_VERSION')}' --force --no-document"
block 'ensure default gem directories are preserved' do
Dir["#{install_dir}/embedded/lib/ruby/gems/#{ruby_version}.0/gems/*/"].each do |dir|
File.write(File.join(dir, '.gitkeep'), '') if File.directory?(dir)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment