@@ -1306,6 +1306,43 @@ def run
13061306 end
13071307 end
13081308
1309+ describe "when using umask 002 and setgid bit" , :permissions do
1310+ let ( :gems_path ) { bundled_app ( "vendor/#{ Bundler . ruby_scope } /gems" ) }
1311+ let ( :foo_path ) { gems_path . join ( "foo-1.0.0" ) }
1312+
1313+ before do
1314+ build_repo4 do
1315+ build_gem "foo" , "1.0.0" do |s |
1316+ s . write "CHANGELOG.md" , "foo"
1317+ end
1318+ end
1319+
1320+ gemfile <<-G
1321+ source "https://gem.repo4"
1322+ gem 'foo'
1323+ G
1324+
1325+ FileUtils . mkdir_p ( gems_path )
1326+ FileUtils . chmod ( "g+s" , gems_path )
1327+ end
1328+
1329+ it "should create the gem directory with proper permissions" do
1330+ with_umask ( 0o002 ) do
1331+ bundle_config "path vendor"
1332+ bundle :install
1333+ expect ( out ) . to include ( "Bundle complete!" )
1334+ expect ( err ) . to be_empty
1335+ # Linux's SysV-derived mkdir(2) propagates the set-group-ID bit
1336+ # from the parent directory to newly created subdirectories. BSD
1337+ # (including macOS) inherits the parent's group via mkdir(2) but
1338+ # does not copy the set-group-ID bit itself, so the expected
1339+ # mode differs by platform.
1340+ expected = RUBY_PLATFORM . include? ( "darwin" ) ? 0o0775 : 0o2775
1341+ expect ( File . stat ( foo_path ) . mode & 0o7777 ) . to eq ( expected )
1342+ end
1343+ end
1344+ end
1345+
13091346 describe "parallel make" do
13101347 before do
13111348 unless Gem ::Installer . private_method_defined? ( :build_jobs )
0 commit comments