summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Grosser <michael@grosser.it>2018-04-10 22:12:21 -0700
committerMichael Grosser <michael@grosser.it>2018-04-10 22:22:31 -0700
commitc8ab9eb049da8f1de58fa9d93ff124f1a45b85e1 (patch)
treecbf7bcb48049c441036b8f556e8046d82682ac73
parentba49ed283fa20d313f95cdefcd32f8f82a786c9f (diff)
downloadbundler-c8ab9eb049da8f1de58fa9d93ff124f1a45b85e1.tar.gz
Do not blow up when installing on a readonly filesystem without a home directory
fixes https://github.com/bundler/bundler/issues/6461 ``` docker run --read-only ruby ruby -r bundler/cli -e "puts Bundler::VERSION; Bundler::CLI.start(['exec', 'ruby', '-v'], :debug => true)" /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:193:in `rescue in tmp_home_path': `/root` is not writable. (Bundler::GenericSystemCallError) Bundler also failed to create a temporary home directory at `/tmp/bundler/home': There was an error accessing `/tmp/bundler/home`. The underlying system error is Errno::EROFS: Read-only file system @ dir_s_mkdir - /tmp/bundler from /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:181:in `tmp_home_path' from /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:172:in `user_home' from /usr/local/lib/ruby/site_ruby/2.5.0/bundler.rb:197:in `user_bundle_path' from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/plugin.rb:99:in `global_root' from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/plugin/index.rb:73:in `global_index_file' from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/plugin/index.rb:32:in `initialize' from /usr/local/lib/ruby/site_ruby/2.5.0/bundler/plugin.rb:78:in `new' ```
-rw-r--r--lib/bundler/plugin/index.rb7
-rw-r--r--spec/bundler/plugin/index_spec.rb8
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb
index cd7a5093b3..642e7c8163 100644
--- a/lib/bundler/plugin/index.rb
+++ b/lib/bundler/plugin/index.rb
@@ -29,7 +29,12 @@ module Bundler
@hooks = {}
@load_paths = {}
- load_index(global_index_file, true)
+ begin
+ load_index(global_index_file, true)
+ rescue GenericSystemCallError
+ # no need to fail when on a read-only FS, for example
+ nil
+ end
load_index(local_index_file) if SharedHelpers.in_bundle?
end
diff --git a/spec/bundler/plugin/index_spec.rb b/spec/bundler/plugin/index_spec.rb
index 163b563b2a..ca3476ea2a 100644
--- a/spec/bundler/plugin/index_spec.rb
+++ b/spec/bundler/plugin/index_spec.rb
@@ -175,4 +175,12 @@ RSpec.describe Bundler::Plugin::Index do
include_examples "it cleans up"
end
end
+
+ describe "readonly disk without home" do
+ it "ignores being unable to create temp home dir" do
+ expect_any_instance_of(Bundler::Plugin::Index).to receive(:global_index_file).
+ and_raise(Bundler::GenericSystemCallError.new("foo", "bar"))
+ Bundler::Plugin::Index.new
+ end
+ end
end