i know nothing about ruby, can anyone help explaining what this script is doing please?
#!/usr/bin/env ruby
begin
require '/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler'
# Check if an older version of bundler is installed(this part i understand)
$:.each do |path|
if path =~ %r'/bundler-0.(\d+)' && $1.to_i < 9
err = "Please remove Bundler 0.8 versions."
err << "This can be done by running `gem cleanup bundler`."
abort(err)
end
end
#it is from here that i dont understand
require '/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/cli'
Bundler::CLI.start
rescue Bundler::BundlerError => e
Bundler.ui.error e.message
Bundler.ui.debug e.backtrace.join("\n")
exit e.status_code
rescue Interrupt => e
Bundler.ui.error "\nQuitting..."
Bundler.ui.debug e.backtrace.join("\n")
exit 1
end
here my irb test:
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/bin$ irb
irb(main):001:0> require 'bundler'
LoadError: no such file to load -- bundler
from (irb):1:in `require'
from (irb):1
from :0
irb(main):002:0> require 'bundler/cli'
LoadError: no such file to load -- bundler/cli
from (irb):2:in `require'
from (irb):2
from :0
irb(main):003:0> Bundler::CLI.start
NameError: uninitialized constant Bundler
from (irb):3
from :0
irb(main):004:0>
thanks
It’s trying to start the bundler CLI, and if it gets a BundlerError or is interrupted it’ll print the stacktrace and exit with a status code. Run the same code from an irb in a directory with a Gemfile and see what happens. It’ll look like what happens if you do a
bundle installfrom the command line.