All, I hope this question belongs here.

I am following a Blockgeeks tutorial, trying to set up my environment for Ethereum blockchain development. I have basically gotten to the final step, installing swarm. When I attempt this command: $ go install -v ./cmd/swarm, it gives me this error:

> unexpected directory layout:
>         import path: github.com/naoina/toml
>         root: C:\cygwin64\home\di203179\go\src
>         dir: C:\cygwin64\home\di203179\go\src\github.com\ethereum\go-ethereum\vendor\github.com\naoina\toml
>         expand root: C:\cygwin64\home\di203179\go\src
>         expand dir: C:\cygwin64\home\di203179\go\src\github.com\ethereum\go-ethereum\vendor\github.com\naoina\toml
>         separator: \

I have tried to find a solution for days now, but nothing I've found has worked. Any help is appreciated.

Handy info:

-OS: Windows 10, running this project within cygwin with proper gcc dependencies installed

-Go version: 1.11.4

-The video link, though I don't know if you can view it without a subscription: https://courses.blockgeeks.com/lesson/blockchain-explained-3/?wvideo=khwy8msrx3


Just found the code that details how this error is thrown, but still at a loss. Link to code: https://golang.org/src/cmd/go/internal/load/pkg.go

Snippet relating to my issue:

// dirAndRoot returns the source directory and workspace root
// for the package p, guaranteeing that root is a path prefix of dir.
func dirAndRoot(p *Package) (dir, root string) {
    dir = filepath.Clean(p.Dir)
    root = filepath.Join(p.Root, "src")
    if !str.HasFilePathPrefix(dir, root) || p.ImportPath != "command-line-arguments" && filepath.Join(root, p.ImportPath) != dir {
        // Look for symlinks before reporting error.
        dir = expandPath(dir)
        root = expandPath(root)

    if !str.HasFilePathPrefix(dir, root) || len(dir) <= len(root) || dir[len(root)] != filepath.Separator || p.ImportPath != "command-line-arguments" && !p.Internal.Local && filepath.Join(root, p.ImportPath) != dir {
        base.Fatalf("unexpected directory layout:\n"+
            "   import path: %s\n"+
            "   root: %s\n"+
            "   dir: %s\n"+
            "   expand root: %s\n"+
            "   expand dir: %s\n"+
            "   separator: %s",
            filepath.Join(p.Root, "src"),

    return dir, root


I have confirmed that the first if-statement from that snippet is running, and the first three conditions of the second if statement resolve to false (meaning they are not the cause of the error), so that means the last condition that is composed of multiple AND statements must be returning true since the error is throwing. Still can't tell why, though. Thanks for any help.

bumped to the homepage by Community 23 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • Can you provide that tutorial link in your question? – Mahesh Rajput Dec 27 '18 at 5:36
  • @MaheshRajput I just added it. I pay for a membership on their site though so you may not be able to view it... – dillon.harless Dec 27 '18 at 13:30

In my case this was down to a duplicated repo under both GOROOT and GOPATH. Delete the GOROOT copy. The error message and code tell you nothing about the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.