Exception Errno::EPERM on wrappers when installing gem via multi-user RVM
Closed this issue · 4 comments
We have a bunch of Ubuntu 10.04 LTS boxes that have multi-user RVM installed (/usr/local/rvm).
We've recently started seeing errors when installing gems, the errors look like the following:
Exception `Errno::EPERM' at /usr/local/rvm/gems/ruby-2.1.0@global/gems/gem-wrappers-1.2.1/lib/gem-wrappers/installer.rb:39 - Operation not permitted @ chmod_internal - /usr/local/rvm/gems/ruby-2.1.0@rails3.2/wrappers/chef-client
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted @ chmod_internal - /usr/local/rvm/gems/ruby-2.1.0@rails3.2/wrappers/chef-client
RVM: 1.25.10
gem-wrappers: 1.2.1
We're attempting to install the chef gem as the deploy user:
$ id
uid=1001(deploy) gid=1001(deploy) groups=111(admin),1001(deploy),1002(rvm)
$
The files in /usr/local/rvm/gems/ruby-2.1.0@rails3.2/wrappers/ are owned by root:rvm, 755 with SGID:
$ ls -al /usr/local/rvm/gems/ruby-2.1.0@rails3.2/wrappers/
total 84
drwsrwsr-x 2 root rvm 4096 2013-12-30 18:02 .
drwxrwsr-x 10 root rvm 4096 2013-12-30 21:25 ..
-rwxrwxr-x 1 root rvm 297 2013-12-30 21:25 bundle
-rwxrwxr-x 1 root rvm 298 2013-12-30 18:00 bundler
-rwxrwxr-x 1 root rvm 302 2013-12-30 22:13 chef-client
-rwxrwxr-x 1 root rvm 300 2013-12-30 21:55 chef-solo
-rwxrwxr-x 1 root rvm 294 2013-12-30 21:55 erb
-rwxrwxr-x 1 root rvm 297 2013-12-30 18:02 erubis
-rwxrwxr-x 1 root rvm 319 2013-12-30 18:00 executable-hooks-uninstaller
-rwxrwxr-x 1 root rvm 294 2013-12-30 21:55 gem
-rwxrwxr-x 1 root rvm 294 2013-12-30 21:55 irb
-rwxrwxr-x 1 root rvm 296 2013-12-30 21:55 knife
-rwxrwxr-x 1 root rvm 295 2013-12-30 18:02 ohai
-rwxrwxr-x 1 root rvm 295 2013-12-30 18:00 rake
-rwxrwxr-x 1 root rvm 295 2013-12-30 21:55 rdoc
-rwxrwxr-x 1 root rvm 301 2013-12-30 18:02 restclient
-rwxr-xr-x 1 root rvm 293 2013-12-30 21:55 ri
-rwxrwxr-x 1 root rvm 295 2013-12-30 21:55 ruby
-rwxrwxr-x 1 root rvm 295 2013-12-30 21:55 shef
-rwxrwxr-x 1 root rvm 297 2013-12-30 21:55 testrb
-rwxrwxr-x 1 root rvm 293 2013-12-30 18:02 tt
Further details: https://gist.github.com/jasonnoble/f9b2bb31071a9f78f59a
Proposed fix:
lib/gem-wrappers/installer.rb
39c39,43
< File.chmod(0755, file_name)
---
> begin
> File.chmod(0755, file_name)
> rescue Errno::EPERM
> puts "Nothing to see here"
> end
This is a proof of concept, so maybe a better rescue message would be to print a warning if the wrapper was not already 755? Expected #{file_name} to be 0755, but was ....
Another suggestion would be something similar to the warnings you get when running rvm get stable
:
Found 73 files with mode different then '664' or '775',
use --debug
to see the list, run rvmsudo rvm get stable
to fix it., prefix the command with 'rvmsudo' to fix it, if the situation persist report a bug.
released 1.2.2
please test with it
RVM 1.25.11
and gem-wrappers 1.2.2
fixed the issue for us. Thanks for the quick turn around Michal!