lib/licensed/source/bundler.rb
def with_local_configuration
        # force bundler to use the local gem file
        original_bundle_gemfile, ENV["BUNDLE_GEMFILE"] = ENV["BUNDLE_GEMFILE"], gemfile_path.to_s

        if ruby_packer?
          # if running under ruby-packer, set environment from host

          # hack: setting this ENV var allows licensed to use Gem paths outside
          # of the ruby-packer filesystem.  this is needed to find spec sources
          # from the host filesystem
          ENV["ENCLOSE_IO_RUBYC_1ST_PASS"] = "1"
          ruby_version = Gem::ConfigMap[:ruby_version]

          if Licensed::Shell.tool_available?("ruby")
            # set the ruby version in Gem::ConfigMap to the ruby version from the host.
            # this helps Bundler find the correct spec sources and paths
            Gem::ConfigMap[:ruby_version] = host_ruby_version
          else
            # running a ruby-packer-built licensed exe when ruby and bundler aren't available
            # is possible but could lead to errors if the host ruby version doesn't
            # match the built executable's ruby version
            @config.ui.warn <<~WARNING
              Ruby wasn't found when enumerating bundler
              dependencies using the licensed executable.  This can cause a
              ruby mismatch between licensed and bundled dependencies and a
              failure to find gem specifications.

              If licensed is unable to find gem specifications that you believe are present,
              please ensure that ruby and bundler are available and try again.
            WARNING
          end
        end

        # reset all bundler configuration
        ::Bundler.reset!
        # and re-configure with settings for current directory
        ::Bundler.configure

        yield
      ensure
        if ruby_packer?
          # if running under ruby-packer, restore environment after block is finished
          ENV.delete("ENCLOSE_IO_RUBYC_1ST_PASS")
          Gem::ConfigMap[:ruby_version] = ruby_version
        end

        ENV["BUNDLE_GEMFILE"] = original_bundle_gemfile
        # restore bundler configuration
        ::Bundler.reset!
        ::Bundler.configure
      end
# helper to clear all bundler environment around a yielded block
helper to clear all bundler environment around a yielded block
helper to clear all bundler environment around a yielded block
def with_local_configuration
        original_bundle_gemfile, ENV["BUNDLE_GEMFILE"] = ENV["BUNDLE_GEMFILE"], gemfile_path.to_s
        if ruby_packer?
          ENV["ENCLOSE_IO_RUBYC_1ST_PASS"] = "1"
          ruby_version = Gem::ConfigMap[:ruby_version]
          if Licensed::Shell.tool_available?("ruby")
            Gem::ConfigMap[:ruby_version] = host_ruby_version
          else
            @config.ui.warn <<~WARNING
              Ruby wasn't found when enumerating bundler
              dependencies using the licensed executable.  This can cause a
              ruby mismatch between licensed and bundled dependencies and a
              failure to find gem specifications.
              If licensed is unable to find gem specifications that you believe are present,
              please ensure that ruby and bundler are available and try again.
            WARNING
          end
        end
        ::Bundler.reset!
        ::Bundler.configure
        yield
      ensure
        if ruby_packer?
          ENV.delete("ENCLOSE_IO_RUBYC_1ST_PASS")
          Gem::ConfigMap[:ruby_version] = ruby_version
        end
        ENV["BUNDLE_GEMFILE"] = original_bundle_gemfile
        ::Bundler.reset!
        ::Bundler.configure
      end
def with_local_configuration original_bundle_gemfile , ENV [ "BUNDLE_GEMFILE" ] = ENV [ "BUNDLE_GEMFILE" ] , gemfile_path . to_s if ruby_packer? ENV [ "ENCLOSE_IO_RUBYC_1ST_PASS" ] = "1" ruby_version = Gem :: ConfigMap [ :ruby_version ] if Licensed :: Shell . tool_available? ( "ruby" ) Gem :: ConfigMap [ :ruby_version ] = host_ruby_version else @config . ui . warn <<~WARNING 
              Ruby wasn't found when enumerating bundler
              dependencies using the licensed executable.  This can cause a
              ruby mismatch between licensed and bundled dependencies and a
              failure to find gem specifications.

              If licensed is unable to find gem specifications that you believe are present,
              please ensure that ruby and bundler are available and try again.
             WARNING end end :: Bundler . reset! :: Bundler . configure yield ensure if ruby_packer? ENV . delete ( "ENCLOSE_IO_RUBYC_1ST_PASS" ) Gem :: ConfigMap [ :ruby_version ] = ruby_version end ENV [ "BUNDLE_GEMFILE" ] = original_bundle_gemfile :: Bundler . reset! :: Bundler . configure end
helper to clear all bundler environment around a yielded block
helper to clear all bundler environment around a yielded block
# force bundler to use the local gem file # if running under ruby-packer, set environment from host # hack: setting this ENV var allows licensed to use Gem paths outside # of the ruby-packer filesystem.  this is needed to find spec sources # from the host filesystem # set the ruby version in Gem::ConfigMap to the ruby version from the host. # this helps Bundler find the correct spec sources and paths # running a ruby-packer-built licensed exe when ruby and bundler aren't available # is possible but could lead to errors if the host ruby version doesn't # match the built executable's ruby version # reset all bundler configuration # and re-configure with settings for current directory # if running under ruby-packer, restore environment after block is finished # restore bundler configuration