Skip to content

Commit

Permalink
ensure remove BUNDLED WITH remove when no project Gemfile.lock and it…
Browse files Browse the repository at this point in the history
… gets created by build process
  • Loading branch information
tongueroo committed Jan 17, 2019
1 parent c7e39c9 commit dfcbb78
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/jets/builders/ruby_packager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def bundle_install
)
end

remove_bundled_with("#{cache_area}/Gemfile.lock")

# Copy the Gemfile.lock back to the project in case it was updated.
# For example we add the jets-rails to the Gemfile.
copy_back_gemfile_lock
Expand Down Expand Up @@ -136,19 +138,18 @@ def copy_gemfiles(full_project_path)
return unless File.exist?(gemfile_lock)

FileUtils.cp(gemfile_lock, dest)
adjust_gemfile_lock(dest)
end

# Remove the BUNDLED WITH line since we don't control the bundler gem version on AWS Lambda
# And this can cause issues with require 'bundler/setup'
def adjust_gemfile_lock(path)
lines = IO.readlines(path)
def remove_bundled_with(gemfile_lock)
lines = IO.readlines(gemfile_lock)
n = lines.index { |l| l.include?("BUNDLED WITH") }
return unless n

new_lines = lines[0..n-1]
content = new_lines.join('')
IO.write(path, content)
IO.write(gemfile_lock, content)
end

def setup_bundle_config
Expand Down

0 comments on commit dfcbb78

Please sign in to comment.