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
ユーザーが既存の環境変数を保持したいセキュリティポリシーを表します。ユーザーが環境を保護する権限を持っていない場合、セキュリティポリシーはエラーを返す可能性があります。