[前][次][番号順一覧][スレッド一覧]

ruby-changes:62483

From: Nobuyoshi <ko1@a...>
Date: Fri, 31 Jul 2020 21:08:58 +0900 (JST)
Subject: [ruby-changes:62483] ebf008b9ae (master): [rubygems/rubygems] Install plugins to user directory

https://git.ruby-lang.org/ruby.git/commit/?id=ebf008b9ae

From ebf008b9aea71fdf9be8dcc92faae1c024201bf9 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 9 Jul 2020 23:38:34 +0900
Subject: [rubygems/rubygems] Install plugins to user directory

Fixes the `Gem::FilePermissionError` without the privilege.
Initialize `@plugins_dir` to the user gem directory, when
installing with `--user` option.

https://github.com/rubygems/rubygems/commit/21a71ac769

diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 0639672..33171a8 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -184,6 +184,7 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L184
     if options[:user_install]
       @gem_home = Gem.user_dir
       @bin_dir = Gem.bindir gem_home unless options[:bin_dir]
+      @plugins_dir = Gem.plugindir(gem_home)
       check_that_user_bin_dir_is_in_path
     end
   end
diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb
index 49ecc54..e984c70 100644
--- a/test/rubygems/test_gem_installer.rb
+++ b/test/rubygems/test_gem_installer.rb
@@ -776,6 +776,28 @@ gem 'other', version https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_installer.rb#L776
     assert File.exist?(plugin_path), 'plugin not written to install_dir'
   end
 
+  def test_generate_plugins_with_user_install
+    spec = quick_gem 'a' do |s|
+      write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io|
+        io.write "puts __FILE__"
+      end
+
+      s.files += %w[lib/rubygems_plugin.rb]
+    end
+
+    util_build_gem spec
+
+    File.chmod(0555, Gem.plugindir)
+    system_path = File.join(Gem.plugindir, 'a_plugin.rb')
+    user_path = File.join(Gem.plugindir(Gem.user_dir), 'a_plugin.rb')
+    installer = util_installer spec, Gem.dir, :user
+
+    assert_equal spec, installer.install
+
+    assert !File.exist?(system_path), 'plugin not written to user plugins_dir'
+    assert File.exist?(user_path), 'plugin not written to user plugins_dir'
+  end
+
   def test_keeps_plugins_up_to_date
     # NOTE: version a-2 is already installed by setup hooks
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]