Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 789957 - dev-ruby/rubygems-3.0.9 Errno::EACCES: Permission denied @ rb_file_s_rename when trying to bundle install using rubygems > 3.0.3
Summary: dev-ruby/rubygems-3.0.9 Errno::EACCES: Permission denied @ rb_file_s_rename w...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 818718
  Show dependency tree
 
Reported: 2021-05-13 12:21 UTC by Marat Radchenko
Modified: 2023-07-29 04:42 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info output (emerge-info.txt,6.99 KB, text/plain)
2021-05-13 12:21 UTC, Marat Radchenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marat Radchenko 2021-05-13 12:21:05 UTC
Created attachment 708024 [details]
emerge --info output

After upgrading to rubygems > 3.0.3, I can no longer "bundle install" as a non-root user:

$ git clone https://github.com/asciidoctor/asciidoctor-epub3.git
$ cd asciidoctor-epub3
$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching rake 13.0.3
Errno::EACCES: Permission denied @ rb_file_s_rename - (/home/irina/.gem/ruby/2.6.0/cache/rake-13.0.3.gem, /usr/lib64/ruby/gems/2.6.0/cache/rake-13.0.3.gem)
An error occurred while installing rake (13.0.3), and Bundler cannot continue.
Make sure that `gem install rake -v '13.0.3' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  rake

I've created an issue in Rubygems bugtracker, but I suspect it is Gentoo-specific: https://github.com/rubygems/rubygems/issues/4542

This bug DOES NOT reproduce with rubygems 3.0.3 ebuild. This bug DOES reproduce with all later versions (3.0.9, 3.1.6, 3.2.14 and so on).
Comment 1 Tee KOBAYASHI 2021-05-13 15:11:23 UTC
The command bundle (/usr/bin/bundle) belongs to the dev-ruby/bundler package. What version of dev-ruby/bundler are you using? Is it correct that you are using =dev-ruby/bundler-2.1.4 as suggested in the Issue of rubygems/rubygems on GitHub?

It might be possible that specific combinations of versions of dev-ruby/rubygems and dev-ruby/bundler are causing problems. I suggest that you try newer versions of dev-ruby/bundler, although they do not have stable keywords.
Comment 2 Marat Radchenko 2021-05-13 16:23:47 UTC
(In reply to Tee KOBAYASHI from comment #1)
> The command bundle (/usr/bin/bundle) belongs to the dev-ruby/bundler
> package. What version of dev-ruby/bundler are you using? Is it correct that
> you are using =dev-ruby/bundler-2.1.4 as suggested in the Issue of
> rubygems/rubygems on GitHub?
> 
> It might be possible that specific combinations of versions of
> dev-ruby/rubygems and dev-ruby/bundler are causing problems. I suggest that
> you try newer versions of dev-ruby/bundler, although they do not have stable
> keywords.

I am reproducing this with both =dev-ruby/bundler-2.1.4 (current stable) and =dev-ruby/bundler-2.2.17 (latest available in tree).
Comment 3 Marat Radchenko 2021-05-13 16:40:01 UTC
Okay, I see some difference. This is output of `bundle env` with Rubygems 3.2.14 (broken):

$ bundle env
## Environment

```
Bundler       2.2.17
  Platforms   ruby, x86_64-linux
Ruby          2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
  Full Path   /usr/bin/ruby26
  Config Dir  /etc
RubyGems      3.2.14
  Gem Home    /usr/lib64/ruby/gems/2.6.0 <---------------------
  Gem Path    /home/irina/.gem/ruby/2.6.0:/usr/lib64/ruby/gems/2.6.0:/usr/local/lib64/ruby/gems/2.6.0
  User Home   /home/irina
  User Path   /home/irina/.gem/ruby/2.6.0
  Bin Dir     /usr/bin <---------------------
Tools         
  Git         2.26.3
  RVM         not installed
  rbenv       not installed
  chruby      not installed
```

## Bundler Build Metadata

```
Built At          2021-05-05
Git SHA           69cbd6e10e
Released Version  true
```


And this is output of `bundle env` with Rubygems 3.0.3 (working)

$ bundle env
## Environment

```
Bundler       2.2.17
  Platforms   ruby, x86_64-linux
Ruby          2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
  Full Path   /usr/bin/ruby26
  Config Dir  /etc
RubyGems      3.0.3
  Gem Home    /home/irina/.gem/ruby/2.6.0 <---------------------
  Gem Path    /home/irina/.gem/ruby/2.6.0:/usr/local/lib64/ruby/gems/2.6.0:/usr/lib64/ruby/gems/2.6.0
  User Home   /home/irina
  User Path   /home/irina/.gem/ruby/2.6.0
  Bin Dir     /home/irina/.gem/ruby/2.6.0/bin <---------------------
Tools         
  Git         2.26.3
  RVM         not installed
  rbenv       not installed
  chruby      not installed
```

## Bundler Build Metadata

```
Built At          2021-05-05
Git SHA           69cbd6e10e
Released Version  true
```

Note that for some reason "Gem Home" and "Bin Dir" have different values. On 3.0.3 it installs Gems to user dir while on 3.2.4 it tries to install to /usr
Comment 4 Marat Radchenko 2021-05-13 16:50:05 UTC
Ahha! And that is most likely caused by the fact that Rubygems 3.0.3 uses files/gentoo-defaults.rb while Rubygems 3.0.9 uses files/gentoo-defaults-3.rb.

In files/gentoo-defaults.rb, there is:

    def default_dir
      Process.euid == 0 ? local_dir : user_dir
    end

While in files/gentoo-defaults-3.rb, there's something different going on.

This is related to https://bugs.gentoo.org/676946#c2
Comment 5 Marat Radchenko 2021-07-07 11:42:02 UTC
Since rubygems-3.0.3 was removed in https://github.com/gentoo/gentoo/commit/0b5c29a63612cb1a39a2ef56789c01caaee7ddc3, there's no longer a single rubygems version in tree where bundler works under non-root account =/
Comment 6 Hans de Graaff gentoo-dev Security 2021-07-07 18:14:23 UTC
(In reply to Marat Radchenko from comment #5)
> Since rubygems-3.0.3 was removed in
> https://github.com/gentoo/gentoo/commit/
> 0b5c29a63612cb1a39a2ef56789c01caaee7ddc3, there's no longer a single
> rubygems version in tree where bundler works under non-root account =/

Sorry, I wasn't aware that this version was used as a workaround. I've restored the version and will try to tackle the bundler issue later this week or the next.
Comment 7 Marat Radchenko 2021-10-19 07:37:59 UTC
dev-ruby/rubygems-3.0.9 can no longer be used as a workaround because it conflicts with dev-lang/ruby-2.7.x that went stable recently. I possibly could mask the latter, but this is not going to scale even mid-term. The issue is reproducible with dev-lang/ruby-2.7.4 too:

$ bundle update
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching rake 13.0.6 (was 13.0.3)
Errno::EACCES: Permission denied @ rb_file_s_rename - (/home/irina/.gem/ruby/2.7.0/cache/rake-13.0.6.gem, /usr/lib64/ruby/gems/2.7.0/cache/rake-13.0.6.gem)
An error occurred while installing rake (13.0.6), and Bundler cannot continue.
Make sure that `gem install rake -v '13.0.6' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  rake

As I said in comment #4, the root of this issue lies in the difference between files/gentoo-defaults.rb and files/gentoo-defaults-3.rb that was introduced in https://bugs.gentoo.org/676946#c2.

I want to emphasize that current inability to install gems as a non-root user makes Gentoo somewhat unusable for Ruby development.
Comment 8 Hans de Graaff gentoo-dev Security 2021-11-26 10:04:38 UTC
I'm currently testing changes to the gentoo-defaults file with rubygems 3.2.31, which is currently masked for testing. I'd believe this should address the install issues, but I'd be happy to get some feedback on it before unmasking it.

"bundle env" as user:

Bundler       2.2.31
  Platforms   ruby, x86_64-linux
Ruby          2.7.5p203 (2021-11-24 revision f69aeb83146be640995753667fdd6c6f157527f5) [x86_64-linux]
  Full Path   /usr/bin/ruby27
  Config Dir  /etc
RubyGems      3.2.31
  Gem Home    /usr/lib64/ruby/gems/2.7.0
  Gem Path    /home/graaff/.local/share/gem/ruby/2.7.0:/usr/lib64/ruby/gems/2.7.0:/usr/local/lib64/ruby/gems/2.7.0
  User Home   /home/graaff
  User Path   /home/graaff/.local/share/gem/ruby/2.7.0
  Bin Dir     /home/graaff/bin


"bundle env" as root:

Bundler       2.2.31
  Platforms   ruby, x86_64-linux
Ruby          2.7.5p203 (2021-11-24 revision f69aeb83146be640995753667fdd6c6f157527f5) [x86_64-linux]
  Full Path   /usr/bin/ruby27
  Config Dir  /etc
RubyGems      3.2.31
  Gem Home    /usr/lib64/ruby/gems/2.7.0
  Gem Path    /root/.gem/ruby/2.7.0:/usr/lib64/ruby/gems/2.7.0:/usr/local/lib64/ruby/gems/2.7.0
  User Home   /root
  User Path   /root/.gem/ruby/2.7.0
  Bin Dir     /usr/local/bin
Comment 9 Larry the Git Cow gentoo-dev 2021-11-26 10:06:48 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a6a37f10bb8b1cc9c00b6ab7228ee8ffa2f01bff

commit a6a37f10bb8b1cc9c00b6ab7228ee8ffa2f01bff
Author:     Hans de Graaff <graaff@gentoo.org>
AuthorDate: 2021-11-26 10:06:24 +0000
Commit:     Hans de Graaff <graaff@gentoo.org>
CommitDate: 2021-11-26 10:06:37 +0000

    dev-ruby/rubygems: add 3.2.31 with new gentoo profile
    
    This version also updates the gentoo-defaults.rb profile to address
    issues with installing gems directly with rubygems or bundler, either as
    root or as a normal user.
    
    Bug: https://bugs.gentoo.org/789957
    Package-Manager: Portage-3.0.28, Repoman-3.0.3
    Signed-off-by: Hans de Graaff <graaff@gentoo.org>

 dev-ruby/rubygems/Manifest                   |   1 +
 dev-ruby/rubygems/files/gentoo-defaults-5.rb |  65 ++++++++++++++++
 dev-ruby/rubygems/rubygems-3.2.31.ebuild     | 110 +++++++++++++++++++++++++++
 3 files changed, 176 insertions(+)
Comment 10 Larry the Git Cow gentoo-dev 2022-01-16 16:03:42 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=05be1308f64a6ee663e8c2d1a5a7f60caa904b2a

commit 05be1308f64a6ee663e8c2d1a5a7f60caa904b2a
Author:     Hans de Graaff <graaff@gentoo.org>
AuthorDate: 2022-01-16 16:03:27 +0000
Commit:     Hans de Graaff <graaff@gentoo.org>
CommitDate: 2022-01-16 16:03:38 +0000

    dev-ruby/rubygems: add 3.2.33 and update gentoo-defaults
    
    This version uses a new set of defaults that make better use of the
    existing mechanism for configuration and require us to overwrite less
    methods.
    
    Bug: https://bugs.gentoo.org/789957
    Package-Manager: Portage-3.0.28, Repoman-3.0.3
    Signed-off-by: Hans de Graaff <graaff@gentoo.org>

 dev-ruby/rubygems/Manifest                         |  2 +-
 dev-ruby/rubygems/files/gentoo-defaults-5.rb       | 44 +++++++---------------
 ...bygems-3.2.31.ebuild => rubygems-3.2.33.ebuild} |  2 +-
 3 files changed, 15 insertions(+), 33 deletions(-)
Comment 11 Marat Radchenko 2022-01-17 08:49:45 UTC
I've tried unmasking and installing =dev-ruby/rubygems-3.2.33, but still observe the same behavior.

$ bundle update
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.......................
Bundler::PermissionError: There was an error while trying to write to `/usr/lib64/ruby/gems/2.7.0/cache`. It is likely that you need to grant write permissions for that path.
An error occurred while installing rake (13.0.6), and Bundler cannot continue.
Make sure that `gem install rake -v '13.0.6' --source 'https://rubygems.org/'` succeeds before bundling.

Output of `bundle env` says:

## Environment

```
Bundler       2.1.4
  Platforms   ruby, x86_64-linux
Ruby          2.7.5p203 (2021-11-24 revision f69aeb83146be640995753667fdd6c6f157527f5) [x86_64-linux]
  Full Path   /usr/bin/ruby27
  Config Dir  /etc
RubyGems      3.2.33
  Gem Home    /usr/lib64/ruby/gems/2.7.0
  Gem Path    /home/irina/.gem/ruby/2.7.0:/usr/lib64/ruby/gems/2.7.0:/usr/local/lib64/ruby/gems/2.7.0
  User Home   /home/irina
  User Path   /home/irina/.gem/ruby/2.7.0
  Bin Dir     /usr/bin
Tools         
  Git         2.32.0
  RVM         not installed
  rbenv       not installed
  chruby      not installed
```
Comment 12 konsolebox 2023-07-29 04:04:41 UTC
Alternative solution in https://bugs.gentoo.org/911401 if anyone is still having this issue.