Skip to content

Commit

Permalink
Merge pull request #49 from warptools/fixups
Browse files Browse the repository at this point in the history
Fixups
  • Loading branch information
Morganamilo authored Jan 5, 2023
2 parents 8d3838b + 77ebc96 commit b7c63ef
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ MODULE := $(shell go list -m)

install:
@echo "Installing plugins..."
mkdir -p $(GOBIN)
cp ./plugins/* $(GOBIN)
@echo "Building and installing warpforge..."
go install ./...
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ warpforge quickstart hello-world

```
Successfully created module.wf and plot.wf for module "hello-world".
Ensure your catalogs are up to date by running `warpforge catalog update.`.
Ensure your catalogs are up to date by running `warpforge catalog update`.
You can check status of this module with `warpforge status`.
You can run this module with `warpforge run`.
Once you've run the Hello World example, edit the 'script' section of plot.wf to customize what happens.
Expand Down
17 changes: 7 additions & 10 deletions cmd/warpforge/internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/serum-errors/go-serum"

"github.com/warptools/warpforge/pkg/dab"
"github.com/warptools/warpforge/pkg/formulaexec"
"github.com/warptools/warpforge/pkg/plotexec"
"github.com/warptools/warpforge/pkg/tracing"
"github.com/warptools/warpforge/pkg/workspace"
Expand All @@ -35,23 +36,19 @@ func GetFileType(name string) (string, error) {
return strings.TrimSuffix(filepath.Base(name), ext), nil
}



// BinPath is a helper function for finding the path to internally used binaries (e.g, rio, runc)
//
// Errors:
//
// - warpforge-error-unknown -- When the path to this executable can't be found
// - warpforge-error-io -- When the path to this executable can't be found
func BinPath(bin string) (string, error) {
path, override := os.LookupEnv("WARPFORGE_PATH")
if override {
return filepath.Join(path, bin), nil
}

path, err := os.Executable()
path, err := formulaexec.GetBinPath()
if err != nil {
return "", serum.Errorf(wfapi.ECodeUnknown, "unable to get path of warpforge executable: %w", err)
return "", err
}

return filepath.Join(filepath.Dir(path), bin), nil
return filepath.Join(path, bin), nil
}

// OpenWorkspaceSet opens the default WorkspaceSet.
Expand Down
2 changes: 1 addition & 1 deletion cmd/warpforge/quickstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func cmdQuickstart(c *cli.Context) error {

if !c.Bool("quiet") {
fmt.Fprintf(c.App.Writer, "Successfully created %s and %s for module %q.\n", util.ModuleFilename, util.PlotFilename, moduleName)
fmt.Fprintf(c.App.Writer, "Ensure your catalogs are up to date by running `%s catalog update.`.\n", os.Args[0])
fmt.Fprintf(c.App.Writer, "Ensure your catalogs are up to date by running `%s catalog update`.\n", os.Args[0])
fmt.Fprintf(c.App.Writer, "You can check status of this module with `%s status`.\n", os.Args[0])
fmt.Fprintf(c.App.Writer, "You can run this module with `%s run`.\n", os.Args[0])
fmt.Fprintf(c.App.Writer, "Once you've run the Hello World example, edit the 'script' section of %s to customize what happens.\n", util.PlotFilename)
Expand Down
6 changes: 5 additions & 1 deletion pkg/formulaexec/formula_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,11 @@ func GetBinPath() (string, error) {
// other binaries (runc, rio) will be located here as well
path, override := os.LookupEnv("WARPFORGE_PATH")
if override {
return path, nil
abs, err := filepath.Abs(path)
if err != nil {
return "", wfapi.ErrorIo("failed to canonicalize WARPFORGE_PATH", path, err)
}
return abs, nil
} else {
binPath, err := os.Executable()
if err != nil {
Expand Down

0 comments on commit b7c63ef

Please sign in to comment.