Repository: superfly/flyctl (Go)

Issue:
Incorrect file referenced in WARN message
*Please only report specific issues with `flyctl` behavior*. Anything like a support request for your application should go to https://community.fly.io. More people watch that space and can help you faster!

**Describe the bug**
Typo in _fly launch_ refers to "from fly.toml" even if a custom file has been specified. The correct text for the WARN is that it should say "from flyNext.toml".

See last line of output.

* Operating system
fly v0.3.53 darwin/arm64 Commit: 7608a703e4eacb1440e9a038c88591cdca944fa2 BuildDate: 2024-12-18T00:30:08Z

```text
Waiting for launch data... Done
Created app '.....' in organization '....'
Admin URL: https://fly.io/apps/[app-name]
Hostname: [hostname].fly.dev
Wrote config file flyNext.toml
Validating /Users/[name]/Documents/projects/[name]/flyNext.toml
✓ Configuration is valid
==> Building image
WARN Ignoring /Users/[name]/Documents/projects/[name]/Dockerfile,
 and using /Users/[name]/Documents/projects/[name]/DockerfileNext (from fly.toml).
```



Discussion:
Thanks! #4138 will fix the warning message.



Patch:
diff --git a/internal/command/deploy/deploy_build.go b/internal/command/deploy/deploy_build.go
index dd0c50167f..6454851d6e 100644
--- a/internal/command/deploy/deploy_build.go
+++ b/internal/command/deploy/deploy_build.go
@@ -42,7 +42,7 @@ func multipleDockerfile(ctx context.Context, appConfig *appconfig.Config) error
 	}
 
 	if found != config {
-		return fmt.Errorf("Ignoring %s, and using %s (from fly.toml).", found, config)
+		return fmt.Errorf("ignoring %s, and using %s (from %s)", found, config, appConfig.ConfigFilePath())
 	}
 	return nil
 }
@@ -78,7 +78,7 @@ func determineImage(ctx context.Context, appConfig *appconfig.Config, useWG, rec
 
 	if err := multipleDockerfile(ctx, appConfig); err != nil {
 		span.AddEvent("found multiple dockerfiles")
-		terminal.Warnf("%s\n", err.Error())
+		terminal.Warnf("%s", err.Error())
 	}
 
 	resolver := imgsrc.NewResolver(daemonType, client, appConfig.AppName, io, useWG, recreateBuilder)


Test patch:
diff --git a/internal/command/deploy/deploy_build_test.go b/internal/command/deploy/deploy_build_test.go
index 3275f79fba..5a4aac4f51 100644
--- a/internal/command/deploy/deploy_build_test.go
+++ b/internal/command/deploy/deploy_build_test.go
@@ -2,33 +2,38 @@ package deploy
 
 import (
 	"context"
+	"os"
+	"path/filepath"
+	"testing"
+
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 	"github.com/superfly/flyctl/internal/appconfig"
 	"github.com/superfly/flyctl/internal/state"
-	"os"
-	"path/filepath"
-	"testing"
 )
 
 func TestMultipleDockerfile(t *testing.T) {
 	dir := t.TempDir()
 
-	f, err := os.Create(filepath.Join(dir, "Dockerfile"))
+	dockerfile, err := os.Create(filepath.Join(dir, "Dockerfile"))
+	require.NoError(t, err)
+	defer dockerfile.Close() // skipcq: GO-S2307
+
+	flyToml, err := os.Create(filepath.Join(dir, "fly.production.toml"))
 	require.NoError(t, err)
-	defer f.Close() // skipcq: GO-S2307
+	defer flyToml.Close() // skipcq: GO-S2307
+
+	cfg, err := appconfig.LoadConfig(flyToml.Name())
+	require.NoError(t, err)
+	cfg.Build = &appconfig.Build{
+		Dockerfile: "Dockerfile.from-fly-toml",
+	}
 
 	ctx := state.WithWorkingDirectory(context.Background(), dir)
 	err = multipleDockerfile(ctx, &appconfig.Config{})
+
 	assert.NoError(t, err)
 
-	err = multipleDockerfile(
-		ctx,
-		&appconfig.Config{
-			Build: &appconfig.Build{
-				Dockerfile: "Dockerfile.from-fly-toml",
-			},
-		},
-	)
-	assert.Error(t, err)
+	err = multipleDockerfile(ctx, cfg)
+	assert.ErrorContains(t, err, "fly.production.toml")
 }