Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defer the running of bundle install in the rails scanner to the callback #3847

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions scanner/rails.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ func configureRails(sourceDir string, config *ScannerConfig) (*SourceInfo, error
}
}

// attempt to install bundle before proceeding
args := []string{"install"}

if checksPass(sourceDir, fileExists("Gemfile.lock")) {
args = append(args, "--quiet")
}

cmd := exec.Command(bundle, args...)
cmd.Stdin = nil
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

s := &SourceInfo{
Family: "Rails",
Callback: RailsCallback,
Expand Down Expand Up @@ -332,24 +320,24 @@ func RailsCallback(appName string, srcInfo *SourceInfo, plan *plan.LaunchPlan, f
if pendingError != nil {
pendingError = errors.Wrap(pendingError, "Failed to add dockerfile-rails gem")
} else {
cmd = exec.Command(bundle, "install", "--quiet")
cmd.Stdin = nil
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

pendingError = cmd.Run()
if pendingError != nil {
pendingError = errors.Wrap(pendingError, "Failed to install dockerfile-rails gem")
} else {
generatorInstalled = true
}
generatorInstalled = true
}
}
} else {
// proceed using the already installed gem
generatorInstalled = true
}

cmd := exec.Command(bundle, "install", "--quiet")
cmd.Stdin = nil
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

err = cmd.Run()
if err != nil {
return errors.Wrap(pendingError, "Failed to install bundle, exiting")
}

// ensure Gemfile.lock includes the x86_64-linux platform
if out, err := exec.Command(bundle, "platform").Output(); err == nil {
if !strings.Contains(string(out), "x86_64-linux") {
Expand Down
Loading