Issue #17840 has been updated by jaruga (Jun Aruga).


You are right! Thank you for your detailed explanation! I confirmed the files permissions were changed by your steps.

> As for package management, for example Gentoo Portage [removes bundled gems](https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-lang/ruby/ruby-3.0.1.ebuild#n74) and so it has no trouble with permissions of gem-derived files.

It's helpful and interesting for me to see other Linux distribution's cases. As we do not really see a problem for the Fedora RPM Ruby package in the current logic, possibly we will go ahead without change.

I was able to confirm that the installed bundled gem files' permissions are kept without change by just removing the `data_mode` in the `options` (the [code](https://github.com/ruby/ruby/blob/1f255adda93bd7958afc7405026326f630ba4748/tool/rbinstall.rb#L982))

```
$ git diff
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 141b67097b..6bae246af1 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -979,7 +979,6 @@ def install_default_gem(dir, srcdir, bindir)
     :domain => :local,
     :ignore_dependencies => true,
     :dir_mode => $dir_mode,
-    :data_mode => $data_mode,
     :prog_mode => $script_mode,
     :wrappers => true,
     :format_executable => true, 
```

Checking a history of `tool/rbinstall.rb`, it seems the following commits introduced the `data_mode` used in installing gems.

Date:   Tue Jan 13 08:21:51 2015 +0000
rbinstall.rb: reuse options hash
https://github.com/ruby/ruby/commit/79cd3c375711fb835d190d9e51a8de841f260075

Date:   Sun Apr 5 00:34:27 2015 +0000
rbinstall.rb: same options for gems
https://github.com/ruby/ruby/commit/5180de635a93d079070f1c942522cf2a969ec7f8


----------------------------------------
Bug #17840: `make install` overriding file permission with 644
https://bugs.ruby-lang.org/issues/17840#change-91770

* Author: jaruga (Jun Aruga)
* Status: Open
* Priority: Normal
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
On the current latest master `b0b5a4e86ef2740c427f9356a4173a1debf4f79c`, by the following steps, I can see the difference between files permission between installed Ruby's gems directory installed by `make install` and gems directory installed by `gem install`. It seems that the `make install` with `tool/rbinstall.rb` overrides the file permission with 644. Is this intentional? Thanks.


```
$ autoconf
$ ./configure \
  --prefix=${HOME}/local/ruby-master-b0b5a4e \
  --enable-shared
$ make
$ make install
```

```
$ ~/local/ruby-master-b0b5a4e/bin/ruby -v
ruby 3.1.0dev (2021-04-28T18:50:15Z master b0b5a4e86e) [x86_64-linux]

$ ~/local/ruby-master-b0b5a4e/bin/gem -v
3.3.0.dev
```

Then seeing `gems/bundled_gems` file, install the same version's bundled gems to user's directory.

```
$ ~/local/ruby-master-b0b5a4e/bin/gem install -v 2.0.0 --user power_assert
$ ~/local/ruby-master-b0b5a4e/bin/gem install -v 13.0.3 --user rake
$ ~/local/ruby-master-b0b5a4e/bin/gem install -v 3.4.1 --user test-unit
$ ~/local/ruby-master-b0b5a4e/bin/gem install -v 1.2.0 --user rbs
```

Then compare files permissions.

power_assert

```
$ ls -l ~/local/ruby-master-b0b5a4e/lib/ruby/gems/3.1.0/gems/power_assert-2.0.0/bin/
total 8
-rw-r--r--. 1 jaruga jaruga 146 Apr 29 17:07 console
-rw-r--r--. 1 jaruga jaruga  74 Apr 29 17:07 setup


$ ls -l ~/.gem/ruby/3.1.0/gems/power_assert-2.0.0/bin/
total 8
-rwxrwxr-x. 1 jaruga jaruga 146 Apr 29 18:00 console*
-rwxrwxr-x. 1 jaruga jaruga  74 Apr 29 18:00 setup*
```

rake

```
$ ls -l ~/local/ruby-master-b0b5a4e/lib/ruby/gems/3.1.0/gems/rake-13.0.3/bin/
total 24
-rw-r--r--. 1 jaruga jaruga 2841 Apr 29 17:07 bundle
-rw-r--r--. 1 jaruga jaruga   85 Apr 29 17:07 console
-rw-r--r--. 1 jaruga jaruga  787 Apr 29 17:07 rake
-rw-r--r--. 1 jaruga jaruga  787 Apr 29 17:07 rdoc
-rw-r--r--. 1 jaruga jaruga  796 Apr 29 17:07 rubocop
-rw-r--r--. 1 jaruga jaruga   74 Apr 29 17:07 setup

$ ls -l ~/.gem/ruby/3.1.0/gems/rake-13.0.3/bin/
total 24
-rwxr-xr-x. 1 jaruga jaruga 2841 Apr 29 18:00 bundle*
-rwxr-xr-x. 1 jaruga jaruga   85 Apr 29 18:00 console*
-rwxr-xr-x. 1 jaruga jaruga  787 Apr 29 18:00 rake*
-rwxr-xr-x. 1 jaruga jaruga  787 Apr 29 18:00 rdoc*
-rwxr-xr-x. 1 jaruga jaruga  796 Apr 29 18:00 rubocop*
-rwxr-xr-x. 1 jaruga jaruga   74 Apr 29 18:00 setup*
```

rbs

```
$ ls -l ~/local/ruby-master-b0b5a4e/lib/ruby/gems/3.1.0/gems/rbs-1.2.0/bin/
total 40
-rw-r--r--. 1 jaruga jaruga 4369 Apr 29 17:07 annotate-with-rdoc
-rw-r--r--. 1 jaruga jaruga  338 Apr 29 17:07 console
-rw-r--r--. 1 jaruga jaruga 2977 Apr 29 17:07 query-rdoc
-rw-r--r--. 1 jaruga jaruga  200 Apr 29 17:07 rbs-prof
-rw-r--r--. 1 jaruga jaruga 1199 Apr 29 17:07 run_in_md.rb
-rw-r--r--. 1 jaruga jaruga  150 Apr 29 17:07 setup
-rw-r--r--. 1 jaruga jaruga 1856 Apr 29 17:07 sort
-rw-r--r--. 1 jaruga jaruga  103 Apr 29 17:07 steep
-rw-r--r--. 1 jaruga jaruga  710 Apr 29 17:07 test_runner.rb

$ ls -l ~/.gem/ruby/3.1.0/gems/rbs-1.2.0/bin/
total 40
-rwxr-xr-x. 1 jaruga jaruga 4369 Apr 29 18:01 annotate-with-rdoc*
-rwxr-xr-x. 1 jaruga jaruga  338 Apr 29 18:01 console*
-rwxr-xr-x. 1 jaruga jaruga 2977 Apr 29 18:01 query-rdoc*
-rwxr-xr-x. 1 jaruga jaruga  200 Apr 29 18:01 rbs-prof*
-rw-r--r--. 1 jaruga jaruga 1199 Apr 29 18:01 run_in_md.rb
-rwxr-xr-x. 1 jaruga jaruga  150 Apr 29 18:01 setup*
-rwxr-xr-x. 1 jaruga jaruga 1856 Apr 29 18:01 sort*
-rwxr-xr-x. 1 jaruga jaruga  103 Apr 29 18:01 steep*
-rwxr-xr-x. 1 jaruga jaruga  710 Apr 29 18:01 test_runner.rb*
```

test-unit

```
$ ls -l ~/local/ruby-master-b0b5a4e/lib/ruby/gems/3.1.0/gems/test-unit-3.4.1/test/run-test.rb 
-rw-r--r--. 1 jaruga jaruga 620 Apr 29 17:07 /home/jaruga/local/ruby-master-b0b5a4e/lib/ruby/gems/3.1.0/gems/test-unit-3.4.1/test/run-test.rb

$ ls -l ~/.gem/ruby/3.1.0/gems/test-unit-3.4.1/test/run-test.rb 
-rwxr-xr-x. 1 jaruga jaruga 620 Apr 29 18:01 /home/jaruga/.gem/ruby/3.1.0/gems/test-unit-3.4.1/test/run-test.rb*
```



The reason why I choose the files is because I found the following items detected by a lint program in Fedora project. The messages mean that a file with shebang do not have executable bits.

```
rubygem-power_assert.noarch: E: non-executable-script /usr/share/gems/gems/power_assert-1.2.0/bin/console 644 /usr/bin/env ruby
rubygem-power_assert.noarch: E: non-executable-script /usr/share/gems/gems/power_assert-1.2.0/bin/setup 644 /usr/bin/env bash
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/bundle 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/console 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/rake 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/rdoc 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/rubocop 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/setup 644 /usr/bin/env bash
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/annotate-with-rdoc 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/console 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/query-rdoc 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/rbs-prof 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/setup 644 /usr/bin/env bash
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/sort 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/steep 644 /bin/sh 
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/test_runner.rb 644 /usr/bin/env ruby
rubygem-test-unit.noarch: E: non-executable-script /usr/share/gems/gems/test-unit-3.3.7/test/run-test.rb 644 /usr/bin/env ruby
```


Note this ticket is related to the following issue tickets I opened yesterday. It's to suggest to drop development files in the gem file.

* https://github.com/ruby/power_assert/issues/35
* https://github.com/ruby/rake/issues/385
* https://github.com/ruby/rbs/issues/673





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>