Method: Fastlane::Setup#ensure_gemfile_valid!

Defined in:
fastlane/lib/fastlane/setup/setup.rb

#ensure_gemfile_valid!(update_gemfile_if_needed: false) ⇒ Object



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'fastlane/lib/fastlane/setup/setup.rb', line 245

def ensure_gemfile_valid!(update_gemfile_if_needed: false)
  gemfile_content = File.read(gemfile_path)
  unless gemfile_content.include?("https://rubygems.org")
    UI.error("You have a local Gemfile, but RubyGems isn't defined as source")
    UI.error("Please update your Gemfile at path `#{gemfile_path}` to include")
    UI.important("")
    UI.important("source \"https://rubygems.org\"")
    UI.important("")
    UI.error("Update your Gemfile, and run `bundle update` afterwards")
  end

  unless gemfile_content.include?("fastlane")
    if update_gemfile_if_needed
      gemfile_content << "\n\ngem \"fastlane\""
      UI.message("Adding `fastlane` to your existing Gemfile at path '#{gemfile_path}'")

      File.write(gemfile_path, gemfile_content)
    else
      UI.error("You have a local Gemfile, but it doesn't include \"fastlane\" as a dependency")
      UI.error("Please add `gem \"fastlane\"` to your Gemfile")
    end
  end
end