-
Notifications
You must be signed in to change notification settings - Fork 204
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
Dapr Init panic: runtime error: invalid memory address or nil pointer dereference #1468
Comments
Received the same error running
Installed DAPR CLI using for Mac M2 Ultra
|
Don't have time to dive into it tonight, will try to track down the nil pointer deference somewhere in the call stack below. https://github.com/dapr/cli/blob/master/pkg/version/version.go#L106 // GetLatestReleaseGithub return the latest release version of dapr from GitHub API.
func GetLatestReleaseGithub(githubURL string) (string, error) {
return GetVersionFromURL(githubURL, func(body []byte) (string, error) {
var githubRepoReleases []githubRepoReleaseItem
err := json.Unmarshal(body, &githubRepoReleases)
if err != nil {
return "", err
}
if len(githubRepoReleases) == 0 {
return "", fmt.Errorf("no releases")
}
defaultVersion, _ := version.NewVersion("0.0.0")
latestVersion := defaultVersion
for _, release := range githubRepoReleases {
if !strings.Contains(release.TagName, "-rc") {
cur, _ := version.NewVersion(strings.TrimPrefix(release.TagName, "v"))
if cur.GreaterThan(latestVersion) {
latestVersion = cur
}
}
} https://github.com/hashicorp/go-version/blob/v1.6.0/version.go // Version represents a single version.
type Version struct {
metadata string
pre string
segments []int64
si int
original string
} // NewVersion parses the given version and returns a new
// Version.
func NewVersion(v string) (*Version, error) {
return newVersion(v, versionRegexp)
}
// NewSemver parses the given version and returns a new
// Version that adheres strictly to SemVer specs
// https://semver.org/
func NewSemver(v string) (*Version, error) {
return newVersion(v, semverRegexp)
}
func newVersion(v string, pattern *regexp.Regexp) (*Version, error) {
matches := pattern.FindStringSubmatch(v)
if matches == nil {
return nil, fmt.Errorf("Malformed version: %s", v)
}
segmentsStr := strings.Split(matches[1], ".")
segments := make([]int64, len(segmentsStr))
for i, str := range segmentsStr {
val, err := strconv.ParseInt(str, 10, 64)
if err != nil {
return nil, fmt.Errorf(
"Error parsing version: %s", err)
}
segments[i] = val
}
// Even though we could support more than three segments, if we
// got less than three, pad it with 0s. This is to cover the basic
// default usecase of semver, which is MAJOR.MINOR.PATCH at the minimum
for i := len(segments); i < 3; i++ {
segments = append(segments, 0)
}
pre := matches[7]
if pre == "" {
pre = matches[4]
}
return &Version{
metadata: matches[10],
pre: pre,
segments: segments,
si: len(segmentsStr),
original: v,
}, nil
} // GreaterThan tests if this version is greater than another version.
func (v *Version) GreaterThan(o *Version) bool {
return v.Compare(o) > 0
} https://github.com/hashicorp/go-version/blob/v1.6.0/version.go#L114 // Compare compares this version to another version. This
// returns -1, 0, or 1 if this version is smaller, equal,
// or larger than the other version, respectively.
//
// If you want boolean results, use the LessThan, Equal,
// GreaterThan, GreaterThanOrEqual or LessThanOrEqual methods.
func (v *Version) Compare(other *Version) int {
// A quick, efficient equality check
if v.String() == other.String() {
return 0
} // String returns the full version string included pre-release
// and metadata information.
//
// This value is rebuilt according to the parsed segments and other
// information. Therefore, ambiguities in the version string such as
// prefixed zeroes (1.04.0 => 1.4.0), `v` prefix (v1.0.0 => 1.0.0), and
// missing parts (1.0 => 1.0.0) will be made into a canonicalized form
// as shown in the parenthesized examples.
func (v *Version) String() string {
var buf bytes.Buffer
fmtParts := make([]string, len(v.segments))
for i, s := range v.segments {
// We can ignore err here since we've pre-parsed the values in segments
str := strconv.FormatInt(s, 10)
fmtParts[i] = str
}
fmt.Fprintf(&buf, strings.Join(fmtParts, "."))
if v.pre != "" {
fmt.Fprintf(&buf, "-%s", v.pre)
}
if v.metadata != "" {
fmt.Fprintf(&buf, "+%s", v.metadata)
}
return buf.String()
} |
@edwardfward I just ran into this tonight and dug into it. The short of it is that one of the releases returned in the JSON for https://api.github.com/repos/dapr/dapr/releases is DetailsThe stack trace contains a call to version.GetLatestReleaseGithub(fmt.Sprintf("https://api.github.com/repos/%s/%s/releases", DaprGitHubOrg, DaprGitHubRepo)) The constants Running [
{
"url": "https://api.github.com/repos/dapr/dapr/releases/186741665",
"assets_url": "https://api.github.com/repos/dapr/dapr/releases/186741665/assets",
"upload_url": "https://uploads.github.com/repos/dapr/dapr/releases/186741665/assets{?name,label}",
"html_url": "https://github.com/dapr/dapr/releases/tag/vedge",
"id": 186741665,
"author": {
"login": "dapr-bot",
"id": 56698301,
"node_id": "MDQ6VXNlcjU2Njk4MzAx",
"avatar_url": "https://avatars.githubusercontent.com/u/56698301?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/dapr-bot",
"html_url": "https://github.com/dapr-bot",
"followers_url": "https://api.github.com/users/dapr-bot/followers",
"following_url": "https://api.github.com/users/dapr-bot/following{/other_user}",
"gists_url": "https://api.github.com/users/dapr-bot/gists{/gist_id}",
"starred_url": "https://api.github.com/users/dapr-bot/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/dapr-bot/subscriptions",
"organizations_url": "https://api.github.com/users/dapr-bot/orgs",
"repos_url": "https://api.github.com/users/dapr-bot/repos",
"events_url": "https://api.github.com/users/dapr-bot/events{/privacy}",
"received_events_url": "https://api.github.com/users/dapr-bot/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"node_id": "RE_kwDOC3tUwM4LIXOh",
"tag_name": "vedge",
"target_commitish": "master",
"name": "Dapr Runtime vedge",
"draft": false,
"prerelease": true,
"created_at": "2024-11-21T20:25:34Z",
"published_at": "2024-11-21T21:07:51Z",
"assets": [
{
"url": "https://api.github.com/repos/dapr/dapr/releases/assets/208173642",
"id": 208173642, Note that the Reading through the logic for the loop starting at line 118 of pkg/version/version.go: defaultVersion, _ := version.NewVersion("0.0.0")
latestVersion := defaultVersion
for _, release := range githubRepoReleases {
if !strings.Contains(release.TagName, "-rc") {
cur, _ := version.NewVersion(strings.TrimPrefix(release.TagName, "v"))
if cur.GreaterThan(latestVersion) {
latestVersion = cur
}
}
} During the first loop, cur, _ := version.NewVersion(strings.TrimPrefix(release.TagName, "v")) The expression func (v *Version) GreaterThan(o *Version) bool {
return v.Compare(o) > 0
} During this function, The func (v *Version) Compare(other *Version) int {
// A quick, efficient equality check
if v.String() == other.String() {
return 0
} The expression func (v *Version) String() string {
var buf bytes.Buffer
fmtParts := make([]string, len(v.segments)) The expression The solutions that leap to my mind are either of the following:
I hope this helps! |
same problem with version 1.14.1 os:debian 12 |
@dlkinney proposed solution works. thanks for your effort on this |
Same problem here Making the jump to hyperspace... goroutine 1 [running]: CLI version: 1.14.1 |
@dlkinney Thanks for digging into this. I completely blanked on the fact Go allows I forked the // GetLatestReleaseGithub return the latest release version of dapr from GitHub API.
func GetLatestReleaseGithub(githubURL string) (string, error) {
return GetVersionFromURL(githubURL, func(body []byte) (string, error) {
var githubRepoReleases []githubRepoReleaseItem
err := json.Unmarshal(body, &githubRepoReleases)
if err != nil {
return "", err
}
if len(githubRepoReleases) == 0 {
return "", fmt.Errorf("no releases")
}
defaultVersion, _ := version.NewVersion("0.0.0")
latestVersion := defaultVersion
for _, release := range githubRepoReleases {
if !strings.Contains(release.TagName, "-rc") {
cur, curErr := version.NewVersion(strings.TrimPrefix(release.TagName, "v"))
if curErr != nil {
print.WarningStatusEvent(os.Stdout, "Failed to parse version: '%s'", curErr)
continue
}
if cur.GreaterThan(latestVersion) {
latestVersion = cur
}
}
}
if latestVersion.Equal(defaultVersion) {
return "", fmt.Errorf("no releases")
}
return latestVersion.String(), nil
})
}
|
@dlkinney @tgermain-impirica @lidalve @santypr Looks like the errant tag causing the issue has been changed/removed. Recommend another New binary with no errors...should work with the existing binary.
|
Good morning all. My environment is now working. I suspect some form of server side outage that caused an intermittent crash when downloading files. Thank you all for the speedy and thorough engagement! |
Thank you, everyone! |
@tgermain-impirica I am not sure it is completely resolved, may be an issue with I am still seeing the
No issue when I install
|
Thanks, everyone for reporting and troubleshooting the issue! |
@edwardfward Hi, thanks for checking the brew install as well.
|
Thank you, @antontroshin. We appreciate the quick turn on this. |
I have been using Dapr for a while without a problem on my M1 Mac. A coworker of mine tried installing and running dapr init, he got the error. I uninstalled Dapr and reinstalled (Homebrew) and am now receiving the same error. We are stuck, and are in the middle of some critical development!
Expected Behavior
Dapr init should install components and docker containers
Actual Behavior
~ % dapr init
⌛ Making the jump to hyperspace...
ℹ️ Container images will be pulled from Docker Hub
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x101d75b14]
goroutine 1 [running]:
github.com/hashicorp/go-version.(*Version).String(0x0)
/Users/runner/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/hashicorp/[email protected]/version.go:369 +0x34
github.com/hashicorp/go-version.(*Version).Compare(0x0, 0x140006ae000)
/Users/runner/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/hashicorp/[email protected]/version.go:116 +0x24
github.com/hashicorp/go-version.(*Version).GreaterThan(...)
/Users/runner/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/hashicorp/[email protected]/version.go:298
github.com/dapr/cli/pkg/version.GetLatestReleaseGithub.func1({0x140010fa000, 0x35bebd, 0x41e000})
/private/tmp/dapr-cli-20240819-5654-e4cfq9/cli-1.14.1/pkg/version/version.go:124 +0x1c8
github.com/dapr/cli/pkg/version.GetVersionFromURL({0x14000722120, 0x2f}, 0x102b81b28)
/private/tmp/dapr-cli-20240819-5654-e4cfq9/cli-1.14.1/pkg/version/version.go:102 +0x350
github.com/dapr/cli/pkg/version.GetLatestReleaseGithub({0x14000722120?, 0x2b?})
/private/tmp/dapr-cli-20240819-5654-e4cfq9/cli-1.14.1/pkg/version/version.go:107 +0x28
github.com/dapr/cli/pkg/version.GetDaprVersion()
/private/tmp/dapr-cli-20240819-5654-e4cfq9/cli-1.14.1/pkg/version/version.go:63 +0x60
github.com/dapr/cli/pkg/standalone.Init({0x10219fc59, 0x6}, {0x10219fc59, 0x6}, {0x0, 0x0}, 0x0, {0x0, 0x0}, {0x0, ...}, ...)
/private/tmp/dapr-cli-20240819-5654-e4cfq9/cli-1.14.1/pkg/standalone/standalone.go:215 +0x1b8
github.com/dapr/cli/cmd.init.func23(0x103ed13e0, {0x10219cde4?, 0x4?, 0x10219ceac?})
/private/tmp/dapr-cli-20240819-5654-e4cfq9/cli-1.14.1/cmd/init.go:174 +0x2e8
github.com/spf13/cobra.(*Command).execute(0x103ed13e0, {0x103f2dc00, 0x0, 0x0})
/Users/runner/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0x81c
github.com/spf13/cobra.(*Command).ExecuteC(0x103ecee80)
/Users/runner/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
/Users/runner/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:1039
github.com/dapr/cli/cmd.Execute({0x10251df40?, 0x10091443c?}, {0x10251df3c?, 0x140000021c0?})
/private/tmp/dapr-cli-20240819-5654-e4cfq9/cli-1.14.1/cmd/dapr.go:78 +0x150
main.main()
/private/tmp/dapr-cli-20240819-5654-e4cfq9/cli-1.14.1/main.go:27 +0x3c
~ %
Steps to Reproduce the Problem
dapr init
Environment
Mac M1 Pro
Dapr version
~ % dapr version
CLI version: 1.14.1
Runtime version: n/a
~ %
The text was updated successfully, but these errors were encountered: