rubygems / bundler

Manage your Ruby application's gem dependencies
https://bundler.io
MIT License
4.88k stars 1.99k forks source link

Errno::EPERM: Operation not permitted @ chown_internal in v1.16.2 #6535

Closed titopandub closed 6 years ago

titopandub commented 6 years ago

Errno::EPERM: Operation not permitted @ chown_internal in v1.16.2

Expected Behavior

bundle install should run normally without error

Current Behavior

Here are the error message:

Fetching gem metadata from https://rubygems.org/..........
Fetching rake 12.3.0
Installing rake 12.3.0
Errno::EPERM: Operation not permitted @ chown_internal -
/tmp/bundler20180517-11343-fttco1rake-12.3.0/bin
An error occurred while installing rake (12.3.0), and Bundler cannot continue.
Make sure that `gem install rake -v '12.3.0' --source 'https://rubygems.org/'`
succeeds before bundling.

Possible Solution

I don't know, right now we only revert back to 1.16.1

Steps to Reproduce

  1. Install chruby 0.3.9
  2. Install ruby 2.4.1
  3. Install bundler 1.16.2
  4. bundle install for Rails project
hsbt commented 6 years ago

I couldn't reproduce it.

~/D/bundle > cat Gemfile
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

#gem "rails"
gem "rake"
~/D/bundle > bundle ins
Fetching gem metadata from https://rubygems.org/.
Using bundler 1.16.2
Fetching rake 12.3.1
Installing rake 12.3.1
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

Can you show the result of bundle env?

titopandub commented 6 years ago

Environment

Bundler       1.16.2
  Platforms   ruby, x86_64-linux
Ruby          2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
  Full Path   /opt/rubies/ruby-2.4.1/bin/ruby
  Config Dir  /opt/rubies/ruby-2.4.1/etc
RubyGems      2.6.11
  Gem Home    /home/ubuntu/.gem/ruby/2.4.1
  Gem Path    /home/ubuntu/.gem/ruby/2.4.1:/opt/rubies/ruby-2.4.1/lib/ruby/gems/2.4.0
  User Path   /home/ubuntu/.gem/ruby/2.4.0
  Bin Dir     /home/ubuntu/.gem/ruby/2.4.1/bin
Tools
  Git         2.7.4
  RVM         not installed
  rbenv       not installed
  chruby      0.3.9

Bundler Build Metadata

Built At          2018-05-16
Git SHA           9f7bf0ac3
Released Version  true

Bundler settings

without
  Set for your local app (/home/ubuntu/ets/dashboard/.bundle/config): [:development, :test]

Gemfile

Gemfile

source 'https://rubygems.org'

gem 'rails', '~> 5.1.4'
gem 'pg', '0.21.0'
gem 'puma', '3.10.0'
gem 'rails_admin', '1.2.0'
gem 'execjs', '2.7.0'
gem 'therubyracer', '0.12.3', :platforms => :ruby
gem 'newrelic_rpm'

group :development, :test do
  gem 'rspec-rails'
  gem 'pry-rails'
  gem 'shoulda-matchers'
  gem 'faker'
  gem 'factory_bot_rails'
end

group :development do
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  # gem 'spring'
  # gem 'spring-watcher-listen', '~> 2.0.0'
end

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (5.1.4)
      actionpack (= 5.1.4)
      nio4r (~> 2.0)
      websocket-driver (~> 0.6.1)
    actionmailer (5.1.4)
      actionpack (= 5.1.4)
      actionview (= 5.1.4)
      activejob (= 5.1.4)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.1.4)
      actionview (= 5.1.4)
      activesupport (= 5.1.4)
      rack (~> 2.0)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.1.4)
      activesupport (= 5.1.4)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    activejob (5.1.4)
      activesupport (= 5.1.4)
      globalid (>= 0.3.6)
    activemodel (5.1.4)
      activesupport (= 5.1.4)
    activerecord (5.1.4)
      activemodel (= 5.1.4)
      activesupport (= 5.1.4)
      arel (~> 8.0)
    activesupport (5.1.4)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (~> 0.7)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    arel (8.0.0)
    builder (3.2.3)
    coderay (1.1.2)
    coffee-rails (4.2.2)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.12.2)
    concurrent-ruby (1.0.5)
    crass (1.0.3)
    diff-lcs (1.3)
    erubi (1.7.0)
    execjs (2.7.0)
    factory_bot (4.8.2)
      activesupport (>= 3.0.0)
    factory_bot_rails (4.8.2)
      factory_bot (~> 4.8.2)
      railties (>= 3.0.0)
    faker (1.8.7)
      i18n (>= 0.7)
    ffi (1.9.18)
    font-awesome-rails (4.7.0.3)
      railties (>= 3.2, < 5.2)
    globalid (0.4.1)
      activesupport (>= 4.2.0)
    haml (5.0.4)
      temple (>= 0.8.0)
      tilt
    i18n (0.9.1)
      concurrent-ruby (~> 1.0)
    jquery-rails (4.3.1)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (5.0.5)
      railties (>= 3.2.16)
    kaminari (1.1.1)
      activesupport (>= 4.1.0)
      kaminari-actionview (= 1.1.1)
      kaminari-activerecord (= 1.1.1)
      kaminari-core (= 1.1.1)
    kaminari-actionview (1.1.1)
      actionview
      kaminari-core (= 1.1.1)
    kaminari-activerecord (1.1.1)
      activerecord
      kaminari-core (= 1.1.1)
    kaminari-core (1.1.1)
    libv8 (3.16.14.19)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.1.1)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.0)
      mini_mime (>= 0.1.1)
    method_source (0.9.0)
    mini_mime (1.0.0)
    mini_portile2 (2.3.0)
    minitest (5.11.1)
    nested_form (0.3.2)
    newrelic_rpm (4.8.0.341)
    nio4r (2.2.0)
    nokogiri (1.8.1)
      mini_portile2 (~> 2.3.0)
    pg (0.21.0)
    pry (0.11.3)
      coderay (~> 1.1.0)
      method_source (~> 0.9.0)
    pry-rails (0.3.6)
      pry (>= 0.10.4)
    puma (3.10.0)
    rack (2.0.3)
    rack-pjax (1.0.0)
      nokogiri (~> 1.5)
      rack (>= 1.1)
    rack-test (0.8.2)
      rack (>= 1.0, < 3)
    rails (5.1.4)
      actioncable (= 5.1.4)
      actionmailer (= 5.1.4)
      actionpack (= 5.1.4)
      actionview (= 5.1.4)
      activejob (= 5.1.4)
      activemodel (= 5.1.4)
      activerecord (= 5.1.4)
      activesupport (= 5.1.4)
      bundler (>= 1.3.0)
      railties (= 5.1.4)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    rails_admin (1.2.0)
      builder (~> 3.1)
      coffee-rails (~> 4.0)
      font-awesome-rails (>= 3.0, < 5)
      haml (>= 4.0, < 6)
      jquery-rails (>= 3.0, < 5)
      jquery-ui-rails (~> 5.0)
      kaminari (>= 0.14, < 2.0)
      nested_form (~> 0.3)
      rack-pjax (>= 0.7)
      rails (>= 4.0, < 6)
      remotipart (~> 1.3)
      sass-rails (>= 4.0, < 6)
    railties (5.1.4)
      actionpack (= 5.1.4)
      activesupport (= 5.1.4)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (12.3.0)
    rb-fsevent (0.10.2)
    rb-inotify (0.9.10)
      ffi (>= 0.5.0, < 2)
    ref (2.0.0)
    remotipart (1.3.1)
    rspec-core (3.7.1)
      rspec-support (~> 3.7.0)
    rspec-expectations (3.7.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.7.0)
    rspec-mocks (3.7.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.7.0)
    rspec-rails (3.7.2)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 3.7.0)
      rspec-expectations (~> 3.7.0)
      rspec-mocks (~> 3.7.0)
      rspec-support (~> 3.7.0)
    rspec-support (3.7.0)
    ruby_dep (1.5.0)
    sass (3.5.5)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sass-rails (5.0.7)
      railties (>= 4.0.0, < 6)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    shoulda-matchers (3.1.2)
      activesupport (>= 4.0.0)
    sprockets (3.7.1)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    temple (0.8.0)
    therubyracer (0.12.3)
      libv8 (~> 3.16.14.15)
      ref
    thor (0.20.0)
    thread_safe (0.3.6)
    tilt (2.0.8)
    tzinfo (1.2.4)
      thread_safe (~> 0.1)
    websocket-driver (0.6.5)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)

PLATFORMS
  ruby

DEPENDENCIES
  execjs (= 2.7.0)
  factory_bot_rails
  faker
  listen (>= 3.0.5, < 3.2)
  newrelic_rpm
  pg (= 0.21.0)
  pry-rails
  puma (= 3.10.0)
  rails (~> 5.1.4)
  rails_admin (= 1.2.0)
  rspec-rails
  shoulda-matchers
  therubyracer (= 0.12.3)

BUNDLED WITH
   1.16.1
amygitsthings commented 6 years ago

I'm running into the same issue with 1.16.2. I'm fine when I revert back to 1.16.1. I know in my case, I'm using rvm system wide and I notice the folder that fails to chown is the bin folder which is owned by root instead of myuser.

[myuser@localhost folder]$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching Selenium 1.1.14
Installing Selenium 1.1.14
Errno::EPERM: Operation not permitted @ chown_internal - /tmp/bundler20180517-9326-wze35rSelenium-1.1.14/bin
An error occurred while installing Selenium (1.1.14), and Bundler cannot continue.
Make sure that `gem install Selenium -v '1.1.14' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  Selenium
[myuser@localhost folder]$ ls -l /tmp/bundler20180517-9326-wze35rSelenium-1.1.14/
total 0
drwxr-xr-x. 2 root   root    6 May 17 13:16 bin
drwxrwxr-x. 2 myuser myuser  6 May 17 13:16 build_info
drwxrwxr-x. 2 myuser myuser  6 May 17 13:16 cache
drwxrwxr-x. 2 myuser myuser  6 May 17 13:16 doc
drwxrwxr-x. 2 myuser myuser  6 May 17 13:16 extensions
drwxrwxr-x. 3 myuser myuser 29 May 17 13:16 gems
drwxrwxr-x. 2 myuser myuser  6 May 17 13:16 specifications

Environment

Bundler             1.16.2
  Platforms         ruby, x86_64-linux
Ruby                2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
  Full Path         /usr/local/rvm/rubies/ruby-2.4.1/bin/ruby
  Config Dir        /etc
RubyGems            2.6.14
  Gem Home          /usr/local/rvm/gems/ruby-2.4.1
  Gem Path          /usr/local/rvm/gems/ruby-2.4.1:/usr/local/rvm/gems/ruby-2.4.1@global
  User Path         /home/myuser/.gem/ruby/2.4.0
  Bin Dir           /usr/local/rvm/gems/ruby-2.4.1/bin
Tools               
  Git               1.8.3.1
  RVM               1.29.3 (latest)
  rbenv             not installed
  chruby            not installed
  rubygems-bundler  (1.4.4)

Bundler Build Metadata

Built At          2018-05-16
Git SHA           9f7bf0ac3
Released Version  true
scott-lewis-nsidc commented 6 years ago

I also experienced this issue:

$ bundle install
Fetching gem metadata from http://rubygems.org/............
Fetching rake 12.0.0
Installing rake 12.0.0
Errno::EPERM: Operation not permitted @ chown_internal - /tmp/bundler20180517-24720-1nemz80rake-12.0.0/bin
An error occurred while installing rake (12.0.0), and Bundler cannot continue.
Make sure that `gem install rake -v '12.0.0' --source 'http://rubygems.org/'` succeeds before bundling.

In Gemfile:
  jasmine was resolved to 2.6.0, which depends on
    rake
$ ls /tmp/bundler20180517-24720-1nemz80rake-12.0.0 -l
total 28
drwxr-xr-x 2 root    root    4096 May 17 11:22 bin
drwx------ 2 vagrant vagrant 4096 May 17 11:22 build_info
drwxrwxr-x 2 vagrant vagrant 4096 May 17 11:22 cache
drwxrwxr-x 2 vagrant vagrant 4096 May 17 11:22 doc
drwxrwxr-x 2 vagrant vagrant 4096 May 17 11:22 extensions
drwxrwxr-x 3 vagrant vagrant 4096 May 17 11:22 gems
drwx------ 2 vagrant vagrant 4096 May 17 11:22 specifications

Environment

Bundler       1.16.2
  Platforms   ruby, x86_64-linux
Ruby          2.4.4p296 (2018-03-28 revision 63013) [x86_64-linux-gnu]
  Full Path   /usr/bin/ruby2.4
  Config Dir  /etc
RubyGems      2.6.14.1
  Gem Home    /var/lib/gems/2.4.0
  Gem Path    /home/vagrant/.gem/ruby/2.4.0:/var/lib/gems/2.4.0:/usr/share/rubygems-integration/2.4.0:/usr/share/rubygems-i
ntegration/all
  User Path   /home/vagrant/.gem/ruby/2.4.0
  Bin Dir     /usr/local/bin
Tools         
  Git         1.9.1
  RVM         not installed
  rbenv       not installed
  chruby      not installed

Bundler Build Metadata

Built At          2018-05-16
Git SHA           9f7bf0ac3
Released Version  true

In my case, this happens when provisioning on a VM using Puppet. The provisioning was working fine until mid-day yesterday (May 16), when it stopped working. When I revert back to bundler 1.16.1, it works fine.

k12u commented 6 years ago

I could produce the similar failure by the procedure shown below:

vagrant init bento/centos-7.4
 => (virtualbox, 201803.24.0)
vagrant up
vagrant ssh
sudo yum groupinstall -y "Development Tools"
sudo yum install -y git openssl-devel readline-devel zlib-devel
git clone git://github.com/rbenv/ruby-build
echo 'source "https://rubygems.org"' > Gemfile
echo 'gem "annotate", "2.7.3"' >> Gemfile

sudo ./ruby-build/bin/ruby-build 2.5.0 old
sudo ./ruby-build/bin/ruby-build 2.5.0 new

sudo ./new/bin/gem install bundler -v 1.16.2
sudo ./old/bin/gem install bundler -v 1.16.1

now while

./old/bin/bundle install

succeeds,

./new/bin/bundle install

fails as shown below:

Fetching gem metadata from https://rubygems.org/.............
Fetching rake 12.3.1
Installing rake 12.3.1
Errno::EPERM: Operation not permitted @ apply2files - /tmp/bundler20180519-21720-c6cgibrake-12.3.1/bin
An error occurred while installing rake (12.3.1), and Bundler cannot continue.
Make sure that `gem install rake -v '12.3.1' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  annotate was resolved to 2.7.3, which depends on
    rake
k12u commented 6 years ago

for some reason, older version allows non-root user to install root-owned gems. (I don't know if it's excepted behavior, but it looks odd to me)

[vagrant@localhost ~]$ ls -l old/lib/ruby/gems/2.5.0/gems/
total 0
drwxr-xr-x. 3 root root  75 May 19 01:14 activemodel-5.2.0
drwxr-xr-x. 4 root root  91 May 19 01:14 activerecord-5.2.0
drwxr-xr-x. 3 root root  75 May 19 01:14 activesupport-5.2.0
drwxr-xr-x. 4 root root 149 May 19 01:14 annotate-2.7.3
drwxr-xr-x. 3 root root  76 May 19 01:14 arel-9.0.0
drwxr-xr-x. 5 root root 117 May 19 01:13 bundler-1.16.1
drwxr-xr-x. 3 root root  73 May 19 01:14 concurrent-ruby-1.0.5
drwxr-xr-x. 7 root root 248 May 19 00:53 did_you_mean-1.2.0
drwxr-xr-x. 5 root root  81 May 19 01:14 i18n-1.0.1
drwxr-xr-x. 4 root root 148 May 19 00:53 minitest-5.10.3
drwxr-xr-x. 4 root root 148 May 19 01:14 minitest-5.11.3
drwxr-xr-x. 4 root root 158 May 19 00:53 net-telnet-0.1.1
drwxr-xr-x. 4 root root 183 May 19 00:53 power_assert-1.1.1
drwxr-xr-x. 6 root root 202 May 19 00:53 rake-12.3.0
drwxr-xr-x. 6 root root 202 May 19 01:14 rake-12.3.1
drwxr-xr-x. 3 root root  17 May 19 00:53 rdoc-6.0.1
drwxr-xr-x. 6 root root 137 May 19 00:53 test-unit-3.2.7
drwxr-xr-x. 8 root root 230 May 19 01:14 thread_safe-0.3.6
drwxr-xr-x. 4 root root 134 May 19 01:14 tzinfo-1.2.5
drwxr-xr-x. 4 root root 154 May 19 00:53 xmlrpc-0.3.0
[vagrant@localhost ~]$ ls -l new/lib/ruby/gems/2.5.0/gems/
total 0
drwxr-xr-x. 5 root root 117 May 19 01:13 bundler-1.16.2
drwxr-xr-x. 7 root root 248 May 19 01:08 did_you_mean-1.2.0
drwxr-xr-x. 4 root root 148 May 19 01:08 minitest-5.10.3
drwxr-xr-x. 4 root root 158 May 19 01:08 net-telnet-0.1.1
drwxr-xr-x. 4 root root 183 May 19 01:08 power_assert-1.1.1
drwxr-xr-x. 6 root root 202 May 19 01:08 rake-12.3.0
drwxr-xr-x. 3 root root  17 May 19 01:08 rdoc-6.0.1
drwxr-xr-x. 6 root root 137 May 19 01:08 test-unit-3.2.7
drwxr-xr-x. 4 root root 154 May 19 01:08 xmlrpc-0.3.0
colby-swandale commented 6 years ago

@k12u Thank you for that steps :bow:, I've pinpointed this issue to #6258

colby-swandale commented 6 years ago

A quick fix to resolve this issue is to update RubyGems to at least 2.7.5

k12u commented 6 years ago

@colby-swandale 👍 confirmed resolution by gem update --system

colby-swandale commented 6 years ago

I have a fix for this issue incoming for people who cannot upgrade RubyGems.

parreirat commented 6 years ago

@colby-swandale Just checking in confirming updating rubygems solved the issue. (setting up RoR on AWS Ubuntu box) Thanks!