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

fastly compute build fails with "EOF" #137

Closed
mccurdyc opened this issue Jun 29, 2020 · 15 comments · Fixed by #248
Closed

fastly compute build fails with "EOF" #137

mccurdyc opened this issue Jun 29, 2020 · 15 comments · Fixed by #248
Assignees
Labels
bug Something isn't working

Comments

@mccurdyc
Copy link
Collaborator

Version
v0.15.0

Please paste the output of fastly version here.

Fastly CLI version 0.15.0 (05a2fe4)
Built with go version go1.14.4 linux/amd64

What happened

Please describe the command you ran, what you expected to happen, and what happened instead.

  1. fastly compute init --path fun
  2. Take all of the defaults
  3. fastly compute build
✓ Initializing...
✓ Verifying package manifest...
✗ Verifying local rust toolchain...

ERROR: error reading cargo metadata: EOF.

If you believe this error is the result of a bug, please file an issue: https://github.com/fastly/cli/issues/new?labels=bug&template=bug_repor
t.md

I expected it to pull down necessary dependencies.

@mccurdyc mccurdyc added the bug Something isn't working label Jun 29, 2020
@mccurdyc
Copy link
Collaborator Author

I dug into this:

  1. Error here
  2. The actual command that gets run is here, namely cargo metadata --format-version 1.

When I ran cargo metadata --format-version 1 directly, I received the following:

    Updating crates.io index
error: failed to get `fastly` as a dependency of package `fastly-template-rust-default v0.1.0 (/tmp/tmp.P6e6ywCZ1p/fun)`

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to authenticate when downloading repository
attempted ssh-agent authentication, but none of the usernames `git` succeeded

Caused by:
  error authenticating: no auth sock variable; class=Ssh (23)

From the above, I knew immediately that I needed to start ssh-agent, but this information was not propagate through the Fastly CLI.

@mccurdyc mccurdyc reopened this Jun 30, 2020
@mccurdyc
Copy link
Collaborator Author

mccurdyc commented Jun 30, 2020

Discussed offline, this is actually a bug as stderr is not being propagated, only stdout. See this.

Instead, we should do something like the following:

        stdout, err := cmd.StdoutPipe()
	if err != nil {
		return err
	}
	stderr, err := cmd.StderrPipe()
	// check and propagate stderr

@fgsch
Copy link
Member

fgsch commented Feb 16, 2021

Just ran into this myself.

fastly version:

Fastly CLI version 0.24.2 (c36d06f)
Built with go version unknown

@fgsch
Copy link
Member

fgsch commented Feb 16, 2021

After some digging, when running cargo within the project directory I was seeing:

error: invalid channel name '[toolchain]' in '/some/path/rust-toolchain'
error: caused by: invalid toolchain name: '[toolchain]'

Reinstalling cargo fixed the problem.

@dkegel-fastly
Copy link
Collaborator

Ran into this myself just now. Definitely agree stderr from cargo metadata should be shown.

@peterbourgon
Copy link
Contributor

Just hit this myself. Very confusing. Would anyone object if I added a special case to the relevant paths to suggest a reinstall of Cargo?

@fgsch
Copy link
Member

fgsch commented Apr 8, 2021

Maybe we should validate the cargo version to ensure [toolchain] is supported?

@peterbourgon
Copy link
Contributor

Oh, it's not because Cargo got messed up, but because the [toolchain] stanza isn't supported in older Cargo versions?

@fgsch
Copy link
Member

fgsch commented Apr 12, 2021

I thought it was cargo but it looks like it is rustup actually:

error: invalid channel name '[toolchain]' in '/PATH/TO/DIRECTORY/rust-toolchain'

it means you're running rustup pre-1.23.0 and trying to interact with a project that uses the new TOML encoding in the rust-toolchain file. You need to upgrade rustup to 1.23.0+.

From https://github.com/rust-lang/rustup/blob/master/doc/src/overrides.md#the-toolchain-file.
I guess I reinstalled both back when I was having this problem.

@fgsch
Copy link
Member

fgsch commented Apr 12, 2021

I wrote some code last night to deal with this case and I will open a PR later today.

@fgsch fgsch self-assigned this Apr 12, 2021
fgsch added a commit that referenced this issue Apr 12, 2021
Turns out, the toolchain section is only available in rustup 1.23.0 and
higher.

Fixes #137.
fgsch added a commit that referenced this issue Apr 12, 2021
Turns out, the toolchain section is only available in rustup 1.23.0 and
higher.

Fixes #137.
fgsch added a commit that referenced this issue Apr 13, 2021
Turns out, the toolchain section is only available in rustup 1.23.0 and
higher.

Fixes #137.
Integralist added a commit that referenced this issue Apr 14, 2021
* Check the rustup version

Turns out, the toolchain section is only available in rustup 1.23.0 and
higher.

Fixes #137.

* Update pkg/compute/rust.go

Co-authored-by: Mark McDonnell <Integralist@users.noreply.github.com>

* Move rustup constraint to the dynamic config

Suggested by @Integralist.

Co-authored-by: Mark McDonnell <Integralist@users.noreply.github.com>
@gaastonsr
Copy link

Btw I have rustup version 1.23.1 (2020-12-03) and I got this error.

$ rustup --version
rustup 1.23.1 (2020-12-03)

@gaastonsr
Copy link

Also, my rustup was installed with Homebrew, so rustup self update didn't work. I fixed it by uninstalling and installing it again using the script from https://rustup.rs/:

$ brew uninstall rustup-init
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

@fgsch
Copy link
Member

fgsch commented May 7, 2021

@gaastonsr That's strange. Did you run rustup --version right after you got this error?
If you try to e.g. install a toolchain, rustup will normally update itself unless you pass --no-self-update.

I tested this fix using rustup installed from Homebrew so I'd like to understand what went wrong.
When you ran rustup self update, was rustup updated, or you got any errors?

@gaastonsr
Copy link

Did you run rustup --version right after you got this error?

I did, and I got 1.23.1 (2020-12-03).

When you ran rustup self update, was rustup updated, or you got any errors?

It didn't update, I got the error:

self-update is disabled for this build of rustup
you should probably use your system package manager to update rustup

@fgsch
Copy link
Member

fgsch commented May 7, 2021

@gaastonsr Thanks. Hmm, I might be misremembering about Homebrew. I tried several combinations back then.
I will try to reproduce it.

fgsch added a commit that referenced this issue May 21, 2021
fgsch added a commit that referenced this issue May 21, 2021
Integralist pushed a commit that referenced this issue May 27, 2021
* Surface any cargo metadata errors

Related to #137 and #269.

* Fix logic

We were showing the verbose output when verbose was NOT set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants