Skip to content

malformed module path "xxx": missing dot in first path element - When path itself is missing #35343

Closed
@spekary

Description

@spekary

Per issue #34184, this is a specific case that causes this error.

What version of Go are you using (go version)?

v1.13.4

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Mac OS 10.14.6

What did you do?

I ran a test on code that had an import path like so:

import mypath/dir/subdir

This code is supposed to be run in a directory that has a go.mod file with a "replace" statement that directs "mypath" to a real directory on the computer, as in:

replace mypath/dir/subdir => ../myproject

However, I did not set that up yet in the go.mod file. Essentially this means that Go was trying to import a path that it could not resolve.

More specifically, here are reproducible steps:

  1. Create a test directory
  2. In the test directory, put the following files:

main.go:

package main
import "a/b/c"

go.mod:

module b
go 1.13
  1. From the test directory, run go run main.go

What did you expect to see?

Since I like errors that offer solutions when available, I like this:

malformed module path "a/b/c": Cannot resolve module path to a directory location. Either install the module, or use a replace statement in a go.mod file to direct it to a location on your disk.

What did you see instead?

cannot load a/b/c: malformed module path "a/b/c": missing dot in first path element

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions