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

Pulumi errors when attempting to use Golang 1.18beta2 #8907

Closed
cstclair-tunein opened this issue Feb 2, 2022 · 1 comment · Fixed by #8920
Closed

Pulumi errors when attempting to use Golang 1.18beta2 #8907

cstclair-tunein opened this issue Feb 2, 2022 · 1 comment · Fixed by #8920
Labels
area/sdks Pulumi language SDKs kind/bug Some behavior is incorrect or out of spec language/go resolution/fixed This issue was fixed

Comments

@cstclair-tunein
Copy link
Contributor

Hello!

  • Vote on this issue by adding a 👍 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

Currently Pulumi is broken when attempting to use Golang 1.18beta2.

It throws the error error: parsing go version: Invalid character(s) found in minor number "18beta2" when you attempt to use Pulumi in any capacity.

❯ pulumi new --force
Please choose a template: aws-go
A minimal AWS Go Pulumi program
This command will walk you through creating a new Pulumi project.

Enter a value or leave blank to accept the (default), and press <ENTER>.
Press ^C at any time to quit.

project name: (pulumi-go-18-issue)
project description: (A minimal AWS Go Pulumi program)
Created project 'pulumi-go-18-issue'

Please enter your desired stack name.
To create a stack in an organization, use the format <org-name>/<stack-name> (e.g. `acmecorp/dev`).
stack name: (dev)
Created stack '[redacted]/dev'

aws:region: The AWS region to deploy into: (us-east-1) us-west-2
Saved config

Installing dependencies...

error: parsing go version: Invalid character(s) found in minor number "18beta2"

Steps to reproduce

  1. Install golang 1.18beta2
  2. Install pulumi
  3. Run pulumi new

Expected: It provisions a pulumi project
Actual: It fails to parse the version and errors.

@cstclair-tunein cstclair-tunein added the kind/bug Some behavior is incorrect or out of spec label Feb 2, 2022
@mikhailshilkov mikhailshilkov added language/go area/sdks Pulumi language SDKs labels Feb 3, 2022
@cstclair-tunein
Copy link
Contributor Author

I have tracked this issue down to this file: https://github.com/pulumi/pulumi/blob/master/sdk/go/common/util/goversion/version.go

The problem is two-fold, and will unfortunately require a decision as opposed to just a bug fix.

  1. the semver library you are relying on, github.com/blang/semver does not actually properly support the semver spec. For example, if I pass that library a semver of the format: 1.0.0-alpha, it will error. However, this is a valid semver!
  2. The Golang language version numbers themselves do not follow semver. That is why 1.18beta2 throws an error: It is not valid according to the semver spec.

The work around I have found: simply trim the beta2 from the version string, like so:

// CheckMinimumGoVersion checks to make sure we are running at least minGoVersion
func CheckMinimumGoVersion(gobin string) error {
	cmd := exec.Command(gobin, "version")
	stdout, err := cmd.Output()
	if err != nil {
		return errors.Wrap(err, "determining go version")
	}

	reg := regexp.MustCompile(`beta[0-9]`)
	res := reg.ReplaceAllString(string(stdout), "")

	return checkMinimumGoVersion(res)
}

However, this is clearly hacky and not suitable for a production product.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdks Pulumi language SDKs kind/bug Some behavior is incorrect or out of spec language/go resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants