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

run xo fails on windows os #387

Open
hossam-houssien opened this issue Feb 8, 2023 · 7 comments
Open

run xo fails on windows os #387

hossam-houssien opened this issue Feb 8, 2023 · 7 comments

Comments

@hossam-houssien
Copy link

ENV info

  • os info
    • Microsoft Windows [Version 10.0.19042.1706]
  • golang info
    • go version go1.20 windows/amd64
    • go version go1.19.5 windows/amd64
    • go version go1.19 windows/amd64
  • xo install
go install github.com/xo/xo@latest

Issue

  • when executing xo command, we got this error
error: createdb: unable to import package: 1:22: import "createdb" error: unable to find source related to: "createdb"
  • we have tried with go versions 1.20 , 1.19.5 and 1.19
@hossam-houssien hossam-houssien changed the title xo run fail on windows run xo fails on windows os Feb 8, 2023
@hhhapz
Copy link
Contributor

hhhapz commented Feb 8, 2023

how did you install xo and what is the exact command you are running?

@hossam-houssien
Copy link
Author

  • I tried install xo using go v1.20 using documented instruction
go install github.com/xo/xo@latest
  • then just running xo without arg or with arg help or --version and it gives the mentioned error.
  • then tried with go v1.19.5 after configuring %GOROOT% to the new go version install dir and removing every thing from %GOPATH%\pkg\mod
  • then tried with go v1.19 with same process as above.

@turnkey-commerce
Copy link
Contributor

On further review it seems like there is an issue with the relative paths in Windows when it tries to import the packages for the templates in templates.go:409:

// import if _, err := i.Eval(fmt.Sprintf("import (xotpl %q)", target)); err != nil { return nil, fmt.Errorf("%s: unable to import package: %w", target, err) }

It's an issue in the yaegi interpreter, "github.com/traefik/yaegi/interp". Not sure how to fix it but will look into it.

@turnkey-commerce
Copy link
Contributor

One thing I tried was to upgrade github.com/traefik/yaegi to v0.15.0 in the go.mod file since it advertises support for Windows. However that didn't work and resulted in the same issue.

@pieter-lazzaro
Copy link

I just encountered this error as well, it looks like the imports are called with Windows path separators which means that the strings.HasPrefix call at templates.go:614 does not match.

It can be fixed by calling filepath.ToSlash on name before doing the comparison.

@turnkey-commerce
Copy link
Contributor

@pieter-lazzaro Thanks, I'll take a look at that.

@turnkey-commerce
Copy link
Contributor

Fixed in PR #391 as suggested by @pieter-lazzaro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants