Repository: pre-commit/pre-commit
Issue: Can't use ruby hooks with "BUNDLE_DISABLE_SHARED_GEMS: true" in .bundle/config

I have a repo with a `.bundle/config` file with these contents:
```yaml
BUNDLE_DISABLE_SHARED_GEMS: true
BUNDLE_PATH: vendor/gem
```

And a `Gemfile` with these contents:
```ruby
gem 'lol_hai'
```

I can't use any Ruby hooks in this repo; I get an error like this:

```
/nail/home/ckuehl/.pre-commit/repobarlh9c4/rbenv-1.9.3-p551/versions/1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:315:in `to_specs': Could not find '__fake_gem' (>= 0) among 0 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/nail/tmp/tmp.jPQDWVcTGz/pre-commit-bug/vendor/gem/ruby/1.9.1', execute `gem env` for more information
        from /nail/home/ckuehl/.pre-commit/repobarlh9c4/rbenv-1.9.3-p551/versions/1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:324:in `to_spec'
        from /nail/home/ckuehl/.pre-commit/repobarlh9c4/rbenv-1.9.3-p551/versions/1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:58:in `gem'
        from /nail/home/ckuehl/.pre-commit/repobarlh9c4/rbenv-1.9.3-p551/gems/bin/puppet-validate:22:in `<main>'
        from /nail/home/ckuehl/.pre-commit/repobarlh9c4/rbenv-1.9.3-p551/gems/bin/ruby_executable_hooks:15:in `eval'
        from /nail/home/ckuehl/.pre-commit/repobarlh9c4/rbenv-1.9.3-p551/gems/bin/ruby_executable_hooks:15:in `<main>'
```

Interesting bit is: `GEM_PATH=/nail/tmp/tmp.jPQDWVcTGz/pre-commit-bug/vendor/gem/ruby/1.9.1`

That doesn't look right (it's a path in my project).


Here's a failing test:

```patch
commit 260f981ae8cdf1c6b1f796dda5cf56811ed237d3 (HEAD -> gemfile-in-root, origin/gemfile-in-root)
Author:     Chris Kuehl <ckuehl@ocf.berkeley.edu>
AuthorDate: Mon Jan 23 19:39:47 2017 -0800
Commit:     Chris Kuehl <ckuehl@yelp.com>
CommitDate: Mon Jan 23 19:59:28 2017 -0800

    Add failing test for BUNDLE_DISABLE_SHARED_GEMS

diff --git a/tests/repository_test.py b/tests/repository_test.py
index b7ce8dd..203852c 100644
--- a/tests/repository_test.py
+++ b/tests/repository_test.py
@@ -207,6 +207,30 @@ def test_run_versioned_ruby_hook(tempdir_factory, store):
     )
 
 
+@skipif_slowtests_false
+@xfailif_windows_no_ruby
+@pytest.mark.integration
+def test_run_ruby_hook_with_disable_shared_gems(
+        tempdir_factory,
+        store,
+        tmpdir,
+):
+    """Make sure a Gemfile in the project doesn't interfere."""
+    tmpdir.join('Gemfile').write('gem "lol_hai"')
+    tmpdir.join('.bundle').mkdir()
+    tmpdir.join('.bundle', 'config').write(
+        'BUNDLE_DISABLE_SHARED_GEMS: true\\n'
+        'BUNDLE_PATH: vendor/gem\\n'
+    )
+    with cwd(tmpdir.strpath):
+        _test_hook_repo(
+            tempdir_factory, store, 'ruby_versioned_hooks_repo',
+            'ruby_hook',
+            ['/dev/null'],
+            b'2.1.5\\nHello world from a ruby hook\\n',
+        )
+
+
 @pytest.mark.integration
 def test_system_hook_with_spaces(tempdir_factory, store):
     _test_hook_repo(
```

Changed files:
tests/repository_test.py, pre_commit/languages/ruby.py

diff --git a/pre_commit/languages/ruby.py b/pre_commit/languages/ruby.py
index 32682f5..d3896d9 100644
--- a/pre_commit/languages/ruby.py
+++ b/pre_commit/languages/ruby.py
@@ -22,6 +22,7 @@ def get_env_patch(venv, language_version):  # pragma: windows no cover
     patches = (
         ('GEM_HOME', os.path.join(venv, 'gems')),
         ('RBENV_ROOT', venv),
+        ('BUNDLE_IGNORE_CONFIG', '1'),
         ('PATH', (
             os.path.join(venv, 'gems', 'bin'), os.pathsep,
             os.path.join(venv, 'shims'), os.pathsep,
diff --git a/tests/repository_test.py b/tests/repository_test.py
index b7ce8dd..203852c 100644
--- a/tests/repository_test.py
+++ b/tests/repository_test.py
@@ -207,6 +207,30 @@ def test_run_versioned_ruby_hook(tempdir_factory, store):
     )
 
 
+@skipif_slowtests_false
+@xfailif_windows_no_ruby
+@pytest.mark.integration
+def test_run_ruby_hook_with_disable_shared_gems(
+        tempdir_factory,
+        store,
+        tmpdir,
+):
+    """Make sure a Gemfile in the project doesn't interfere."""
+    tmpdir.join('Gemfile').write('gem "lol_hai"')
+    tmpdir.join('.bundle').mkdir()
+    tmpdir.join('.bundle', 'config').write(
+        'BUNDLE_DISABLE_SHARED_GEMS: true\\n'
+        'BUNDLE_PATH: vendor/gem\\n'
+    )
+    with cwd(tmpdir.strpath):
+        _test_hook_repo(
+            tempdir_factory, store, 'ruby_versioned_hooks_repo',
+            'ruby_hook',
+            ['/dev/null'],
+            b'2.1.5\\nHello world from a ruby hook\\n',
+        )
+
+
 @pytest.mark.integration
 def test_system_hook_with_spaces(tempdir_factory, store):
     _test_hook_repo(