mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
[rubygems/rubygems] Consistently use :create action when creating directories
It gives better errors. https://github.com/rubygems/rubygems/commit/bedae080ef
This commit is contained in:
parent
88b969cd19
commit
cc29d737ef
@ -493,7 +493,7 @@ module Bundler
|
||||
end
|
||||
|
||||
def mkdir_p(path)
|
||||
SharedHelpers.filesystem_access(path, :write) do |p|
|
||||
SharedHelpers.filesystem_access(path, :create) do |p|
|
||||
FileUtils.mkdir_p(p)
|
||||
end
|
||||
end
|
||||
|
||||
@ -425,8 +425,12 @@ module Bundler
|
||||
Validator.validate!(raw_key, converted_value(value, raw_key), hash)
|
||||
|
||||
return unless file
|
||||
|
||||
SharedHelpers.filesystem_access(file.dirname, :create) do |p|
|
||||
FileUtils.mkdir_p(p)
|
||||
end
|
||||
|
||||
SharedHelpers.filesystem_access(file) do |p|
|
||||
FileUtils.mkdir_p(p.dirname)
|
||||
p.open("w") {|f| f.write(serializer_class.dump(hash)) }
|
||||
end
|
||||
end
|
||||
|
||||
@ -96,7 +96,7 @@ module Bundler
|
||||
# given block
|
||||
#
|
||||
# @example
|
||||
# filesystem_access("vendor/cache", :write) do
|
||||
# filesystem_access("vendor/cache", :create) do
|
||||
# FileUtils.mkdir_p("vendor/cache")
|
||||
# end
|
||||
#
|
||||
|
||||
@ -121,12 +121,13 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow
|
||||
end
|
||||
end
|
||||
|
||||
context "when it's not possible to write to the file" do
|
||||
context "when it's not possible to create the settings directory" do
|
||||
it "raises an PermissionError with explanation" do
|
||||
expect(::Bundler::FileUtils).to receive(:mkdir_p).with(settings.send(:local_config_file).dirname).
|
||||
and_raise(Errno::EACCES)
|
||||
settings_dir = settings.send(:local_config_file).dirname
|
||||
expect(::Bundler::FileUtils).to receive(:mkdir_p).with(settings_dir).
|
||||
and_raise(Errno::EACCES.new(settings_dir.to_s))
|
||||
expect { settings.set_local :frozen, "1" }.
|
||||
to raise_error(Bundler::PermissionError, /config/)
|
||||
to raise_error(Bundler::PermissionError, /#{settings_dir}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -164,12 +165,13 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow
|
||||
end
|
||||
|
||||
describe "#set_global" do
|
||||
context "when it's not possible to write to the file" do
|
||||
context "when it's not possible to write to create the settings directory" do
|
||||
it "raises an PermissionError with explanation" do
|
||||
expect(::Bundler::FileUtils).to receive(:mkdir_p).with(settings.send(:global_config_file).dirname).
|
||||
and_raise(Errno::EACCES)
|
||||
settings_dir = settings.send(:global_config_file).dirname
|
||||
expect(::Bundler::FileUtils).to receive(:mkdir_p).with(settings_dir).
|
||||
and_raise(Errno::EACCES.new(settings_dir.to_s))
|
||||
expect { settings.set_global(:frozen, "1") }.
|
||||
to raise_error(Bundler::PermissionError, %r{\.bundle/config})
|
||||
to raise_error(Bundler::PermissionError, /#{settings_dir}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -890,7 +890,7 @@ RSpec.describe "bundle install with gem sources" do
|
||||
bundle "config set --local path vendor"
|
||||
bundle :install, raise_on_error: false
|
||||
expect(err).to include(bundle_path.to_s)
|
||||
expect(err).to include("grant write permissions")
|
||||
expect(err).to include("grant executable permissions")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user