Forwarded: https://gitlab.com/gitlab-org/gitlab-shell/issues/30
Index: gitlab-shell/bin/check
===================================================================
--- gitlab-shell.orig/bin/check
+++ gitlab-shell/bin/check
@@ -1,7 +1,8 @@
 #!/usr/bin/env ruby
 
-require_relative '../lib/gitlab_init'
-require_relative '../lib/gitlab_net'
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'gitlab_init'
+require 'gitlab_net'
 
 #
 # GitLab shell check task
Index: gitlab-shell/bin/create-hooks
===================================================================
--- gitlab-shell.orig/bin/create-hooks
+++ gitlab-shell/bin/create-hooks
@@ -4,9 +4,10 @@
 #
 # This script is used when restoring a GitLab backup.
 
-require_relative '../lib/gitlab_init'
-require File.join(ROOT_PATH, 'lib', 'gitlab_projects')
-require File.join(ROOT_PATH, 'lib', 'gitlab_metrics')
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'gitlab_init'
+require 'gitlab_projects'
+require 'gitlab_metrics'
 
 repository_storage_paths = ARGV
 
Index: gitlab-shell/bin/gitlab-keys
===================================================================
--- gitlab-shell.orig/bin/gitlab-keys
+++ gitlab-shell/bin/gitlab-keys
@@ -1,6 +1,7 @@
 #!/usr/bin/env ruby
 
-require_relative '../lib/gitlab_init'
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'gitlab_init'
 
 #
 # GitLab Keys shell. Add/remove keys from ~/.ssh/authorized_keys
@@ -17,7 +18,7 @@ require_relative '../lib/gitlab_init'
 #   /bin/gitlab-keys clear
 #
 
-require File.join(ROOT_PATH, 'lib', 'gitlab_keys')
+require 'gitlab_keys'
 
 # Return non-zero if command execution was not successful
 if GitlabKeys.new.exec
Index: gitlab-shell/bin/gitlab-projects
===================================================================
--- gitlab-shell.orig/bin/gitlab-projects
+++ gitlab-shell/bin/gitlab-projects
@@ -1,7 +1,8 @@
 #!/usr/bin/env ruby
 
 
-require_relative '../lib/gitlab_init'
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'gitlab_init'
 
 #
 # GitLab Projects shell. Add/remove projects from /home/git/repositories
@@ -19,7 +20,7 @@ require_relative '../lib/gitlab_init'
 #
 #   /bin/gitlab-projects import-project randx/six.git https://github.com/randx/six.git
 #
-require File.join(ROOT_PATH, 'lib', 'gitlab_projects')
+require 'gitlab_projects'
 
 # Return non-zero if command execution was not successful
 if GitlabProjects.new.exec
Index: gitlab-shell/bin/install
===================================================================
--- gitlab-shell.orig/bin/install
+++ gitlab-shell/bin/install
@@ -1,6 +1,7 @@
 #!/usr/bin/env ruby
 
-require_relative '../lib/gitlab_init'
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'gitlab_init'
 
 #
 # GitLab shell, invoked from ~/.ssh/authorized_keys
Index: gitlab-shell/bin/gitlab-shell
===================================================================
--- gitlab-shell.orig/bin/gitlab-shell
+++ gitlab-shell/bin/gitlab-shell
@@ -8,14 +8,14 @@ end
 key_id = /key-[0-9]+/.match(ARGV.join).to_s
 original_cmd = ENV.delete('SSH_ORIGINAL_COMMAND')
 
-require_relative '../lib/gitlab_init'
+require 'gitlab_init'
 
 #
 #
 # GitLab shell, invoked from ~/.ssh/authorized_keys
 #
 #
-require File.join(ROOT_PATH, 'lib', 'gitlab_shell')
+require 'gitlab_shell'
 
 if GitlabShell.new(key_id).exec(original_cmd)
   exit 0
Index: gitlab-shell/hooks/post-receive
===================================================================
--- gitlab-shell.orig/hooks/post-receive
+++ gitlab-shell/hooks/post-receive
@@ -7,8 +7,9 @@ refs = $stdin.read
 key_id  = ENV.delete('GL_ID')
 repo_path = Dir.pwd
 
-require_relative '../lib/gitlab_custom_hook'
-require_relative '../lib/gitlab_post_receive'
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'gitlab_custom_hook'
+require 'gitlab_post_receive'
 
 if GitlabPostReceive.new(repo_path, key_id, refs).exec &&
     GitlabCustomHook.new(key_id).post_receive(refs, repo_path)
Index: gitlab-shell/hooks/update
===================================================================
--- gitlab-shell.orig/hooks/update
+++ gitlab-shell/hooks/update
@@ -9,7 +9,8 @@ new_value = ARGV[2]
 repo_path = Dir.pwd
 key_id    = ENV.delete('GL_ID')
 
-require_relative '../lib/gitlab_custom_hook'
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'gitlab_custom_hook'
 
 if GitlabCustomHook.new(key_id).update(ref_name, old_value, new_value, repo_path)
   exit 0
Index: gitlab-shell/hooks/pre-receive
===================================================================
--- gitlab-shell.orig/hooks/pre-receive
+++ gitlab-shell/hooks/pre-receive
@@ -8,9 +8,10 @@ key_id = ENV.delete('GL_ID')
 protocol = ENV.delete('GL_PROTOCOL')
 repo_path = Dir.pwd
 
-require_relative '../lib/gitlab_custom_hook'
-require_relative '../lib/gitlab_reference_counter'
-require_relative '../lib/gitlab_access'
+$:.unshift File.expand_path('../lib', __FILE__)
+require 'gitlab_custom_hook'
+require 'gitlab_access'
+require 'gitlab_reference_counter'
 
 # It's important that on pre-receive `increase_reference_counter` gets executed
 # last so that it only runs if everything else succeeded. On post-receive on the
