bin/autoproj_bootstrap in autoproj-2.16.0 vs bin/autoproj_bootstrap in autoproj-2.17.0

- old
+ new

@@ -95,11 +95,13 @@ "workspace is not supported, you need to do a clean bootstrap" end @ruby_executable = config["ruby_executable"] @local = false - install_gems_in_gem_user_dir unless @gems_install_path + @gems_install_path ||= default_gems_install_path + @gems_install_path = File.expand_path(@gems_install_path) + env["GEM_HOME"] = [gems_gem_home] env["GEM_PATH"] = [gems_gem_home] end def env_for_child(env = self.env) @@ -169,28 +171,21 @@ !!@local end # (see #local?) attr_writer :local - # The user-wide place where RubyGems installs gems - def self.dot_gem_dir - if Gem.respond_to?(:data_home) # Debian 11+ - File.join(Gem.data_home, "gem") - else - File.join(Gem.user_home, ".gem") - end - end - - # The version and platform-specific suffix under {#dot_gem_dir} + # The version and platform-specific suffix # # This is also the suffix used by bundler to install gems def self.gems_path_suffix - @gems_path_suffix ||= - Pathname - .new(Gem.user_dir) - .relative_path_from(Pathname.new(dot_gem_dir)) - .to_s + return @gems_path_suffix if @gem_path_suffix + + parts = [Gem.ruby_engine] + unless RbConfig::CONFIG["ruby_version"].empty? + parts << RbConfig::CONFIG["ruby_version"] + end + @gems_path_suffix = File.join parts end # The path into which the workspace's gems should be installed # # They are installed in a versioned subdirectory of this path, e.g. @@ -217,25 +212,25 @@ else default end end - # Install autoproj in Gem's default user dir - def install_gems_in_gem_user_dir + # Get autoproj's default path for installing gems + def default_gems_install_path xdg_default_gem_path = xdg_var("XDG_DATA_HOME", File.join(Dir.home, ".local", "share", "autoproj", "gems")) default_gem_path = File.join( Dir.home, ".autoproj", "gems" ) - @gems_install_path = - if File.directory?(xdg_default_gem_path) - xdg_default_gem_path - elsif File.directory?(default_gem_path) - default_gem_path - else - xdg_default_gem_path - end + + if File.directory?(xdg_default_gem_path) + xdg_default_gem_path + elsif File.directory?(default_gem_path) + default_gem_path + else + xdg_default_gem_path + end end # Whether autoproj should prefer OS-independent packages over their # OS-packaged equivalents (e.g. the thor gem vs. the ruby-thor # Debian package) @@ -267,15 +262,14 @@ # The content of the default {#gemfile} # # @param [String] autoproj_version a constraint on the autoproj version # that should be used # @return [String] - def default_gemfile_contents(autoproj_version = ">= 2.0.0") + def default_gemfile_contents(autoproj_version = ">= 2.16.0") ["source \"#{gem_source}\"", "ruby \"#{RUBY_VERSION}\" if respond_to?(:ruby)", - "gem \"autoproj\", \"#{autoproj_version}\"", - "gem \"utilrb\", \">= 3.0.1\""].join("\n") + "gem \"autoproj\", \"#{autoproj_version}\""].join("\n") end def add_seed_config(path) @config.merge!(YAML.safe_load(File.read(path), [Symbol])) end @@ -295,15 +289,16 @@ opt.on "--gem-source=URL", String, "use this source for RubyGems "\ "instead of rubygems.org" do |url| @gem_source = url end opt.on "--gems-path=PATH", "install gems under this path instead "\ - "of ~/.autoproj/gems" do |path| - self.gems_install_path = path + "of #{default_gems_install_path} (do not use with --public-gems)" do |path| + @gems_install_path = path end - opt.on "--public-gems", "install gems in the default gem location" do - install_gems_in_gem_user_dir + opt.on "--public-gems", "install gems in the default gem location: #{default_gems_install_path}"\ + " (do not use with --gems-path)" do + @gems_install_path = default_gems_install_path end opt.on "--bundler-version=VERSION_CONSTRAINT", String, "use the provided "\ "string as a version constraint for bundler" do |version| @config["bundler_version"] = version end @@ -321,10 +316,11 @@ end opt.on "--no-seed-config", "when reinstalling an existing autoproj workspace, do not "\ "use the config in .autoproj/ as seed" do @config.clear + @config["bundler_version"] = Install.default_bundler_version end opt.on "--seed-config=PATH", String, "path to a seed file that "\ "should be used to initialize the configuration" do |path| add_seed_config(path) end @@ -754,11 +750,21 @@ else config["ruby_executable"] = ruby_executable end @config = config + @config["bundler_version"] ||= self.class.default_bundler_version + %w[gems_install_path prefer_indep_over_os_packages].each do |flag| instance_variable_set "@#{flag}", config.fetch(flag, false) + end + end + + def self.default_bundler_version + if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6.0") + "2.3.6" + elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0.0") + "2.4.22" end end def save_config config["gems_install_path"] = gems_install_path