Ubuntu 14.04 시스템에 Ruby를 다시 설치하려고 하는데 PATH 변수 등을 설정하는 방법이 혼란스럽습니다. 일반 사용자로 시도하면 다양한 권한 거부 오류가 발생합니다.
myuser@myproject:~$ rvm reinstall ruby-2.4.0
mkdir: cannot create directory ‘/usr/local/rvm/log/1496156193_ruby-2.4.0’: Permission denied
tee: /usr/local/rvm/log/1496156193_ruby-2.4.0/remove.rubies.log: No such file or directory
ruby-2.4.0 - #removing rubies/ruby-2.4.0....
Error running '__rvm_rm_rf /usr/local/rvm/rubies/ruby-2.4.0',
showing last 15 lines of /usr/local/rvm/log/1496156193_ruby-2.4.0/remove.rubies.log
tail: cannot open ‘/usr/local/rvm/log/1496156193_ruby-2.4.0/remove.rubies.log’ for reading: No such file or directory
mkdir: cannot create directory ‘/usr/local/rvm/log/1496156193_ruby-2.4.0’: Permission denied
tee: /usr/local/rvm/log/1496156193_ruby-2.4.0/remove.rubies.log: No such file or directory
ruby-2.4.0 - #removing rubies/ruby-2.4.0....
Error running '__rvm_rm_rf /usr/local/rvm/rubies/ruby-2.4.0',
showing last 15 lines of /usr/local/rvm/log/1496156193_ruby-2.4.0/remove.rubies.log
tail: cannot open ‘/usr/local/rvm/log/1496156193_ruby-2.4.0/remove.rubies.log’ for reading: No such file or directory
Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/ubuntu/14.04/x86_64/ruby-2.4.0.tar.bz2
Checking requirements for ubuntu.
Requirements installation successful.
ruby-2.4.0 - #configure
ruby-2.4.0 - #download
ruby-2.4.0 - #validate archive
ruby-2.4.0 - #extract
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/README.md’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/.travis.yml’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/test/dtf/rubygems_comment_test.sh’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/test/dtf/binary_comment_test.sh’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/test/dtf/bundler_comment_test.sh’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/test/dtf/rails_and_gemfile_comment_test.sh’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/CHANGELOG.md’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/LICENSE’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/rubygems-bundler.gemspec’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/lib/rubygems_executable_plugin.rb’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/lib/rubygems-bundler/version.rb’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/lib/rubygems-bundler/noexec.rb’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/Gemfile’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/.noexec.yaml’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/.gem.config’: Permission denied
rm: cannot remove ‘/usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/rubygems-bundler-1.4.4/.gitignore’: Permission denied
mktemp: failed to create directory via template ‘/usr/local/rvm/tmp/rvm-tmp.XXXXXXXXX’: Permission denied
mkdir: cannot create directory ‘’: No such file or directory
tar: : Cannot open: No such file or directory
하지만 sudo로 설치하고 설치하면 "명령을 찾을 수 없음" 오류가 발생합니다.
myuser@myproject:~$ sudo rvm reinstall ruby-2.4.0
sudo: rvm: command not found
일반 사용자처럼 내 rvm 실행 파일을 찾도록 sudo를 어떻게 설정합니까?
답변1
노력하다 sudo -E rvm reinstall ruby-2.4.0
.
에서 man sudo
:
-E, --preserve-env
사용자가 기존 환경 변수를 유지하기를 원하는 보안 정책을 나타냅니다. 사용자에게 환경을 보호할 권한이 없으면 보안 정책에서 오류가 반환될 수 있습니다.