diff options
author | Stan Hu <stanhu@gmail.com> | 2020-03-17 21:18:04 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2020-03-17 21:27:52 +0300 |
commit | 313f95078fe2827c09544fa4bcbf14f3d5f52d21 (patch) | |
tree | 7e7d3aff062767ccc9efea1d75002df652d5a785 | |
parent | 30a14b3ae9896627828ae55f54c788df27ac0797 (diff) |
Fix gitaly-ruby not starting on case-sensitive filesystems
When gitaly-ruby is used on a case-sensitive filesystem, the
`require_relative` calls depend on substitutions based on the directory
of `ruby/lib/gitlab/git.rb`. For example, suppose `/Code/gitaly/ruby`
were used:
1. `__dir__` returns `/code/gitaly/ruby`
2. `Dir.glob` returns files prefixed by `/Code/gitaly/ruby/`
The `require_relative` call in `git.rb` attempts to strip the directory
name from the files returned in step 2, but due to the mismatch the
substitution failed. This prevented gitaly-ruby from starting.
To fix this, we use the canonical name of the directory by calling
`Dir.glob` on that path. Under the hood, `Dir.glob` makes a system call
to `readdir()` to extract this name.
Closes https://gitlab.com/gitlab-org/gitaly/-/issues/2538
-rw-r--r-- | changelogs/unreleased/sh-fix-gitaly-ruby-startup.yml | 5 | ||||
-rw-r--r-- | ruby/lib/gitlab/git.rb | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-fix-gitaly-ruby-startup.yml b/changelogs/unreleased/sh-fix-gitaly-ruby-startup.yml new file mode 100644 index 000000000..2fe9a3dbc --- /dev/null +++ b/changelogs/unreleased/sh-fix-gitaly-ruby-startup.yml @@ -0,0 +1,5 @@ +--- +title: Fix gitaly-ruby not starting on case-sensitive filesystems +merge_request: 1939 +author: +type: fixed diff --git a/ruby/lib/gitlab/git.rb b/ruby/lib/gitlab/git.rb index ef8be707c..b0e87ff75 100644 --- a/ruby/lib/gitlab/git.rb +++ b/ruby/lib/gitlab/git.rb @@ -16,7 +16,11 @@ require_relative 'rails_logger.rb' require_relative 'gollum.rb' require_relative 'config.rb' -dir = __dir__ +# `Dir.glob` will make a readdir() system call to extract the canonical +# name of the directory. This will ensure we avoid errors with +# substitutions below on case-sensitive filesystems such as Apple File +# System. +dir = Dir[__dir__].first # Some later requires are order-sensitive. Manually require whatever we need. require_relative "#{dir}/encoding_helper.rb" |