Skip to content

Commit

Permalink
defer the running of bundle install in the rails scanner to the callback
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Aug 14, 2024
1 parent 1e91c27 commit d69cec8
Showing 1 changed file with 11 additions and 23 deletions.
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

0 comments on commit d69cec8

Please sign in to comment.