rust icon indicating copy to clipboard operation
rust copied to clipboard

Doesn't seem to cache toolchain on 4.x beta

Open arnarthor opened this issue 2 years ago • 4 comments

I'm running the latest beta and it seems to download the toolchain on each commit. It also seems to be downloading the toolchain twice.

These are my build logs. I'm running this in a repo with a Remix app as well, so the build step is building both the Rust lambdas as well as the Remix app, don't know if that would make a difference here.

[23:22:32.626] Running build in San Francisco, USA (West) – sfo1
....
[23:22:52.373] info: downloading installer
[23:22:52.495] error: $HOME differs from euid-obtained home directory: you may be using sudo
[23:22:52.496] error: $HOME directory: /vercel
[23:22:52.496] error: euid-obtained home directory: /root
[23:22:52.515] info: profile set to 'default'
[23:22:52.515] info: default host triple is x86_64-unknown-linux-gnu
[23:22:52.516] info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
[23:22:52.597] info: latest update on 2023-03-28, rust version 1.68.2 (9eb3afe9e 2023-03-27)
[23:22:52.597] info: downloading component 'cargo'
[23:22:52.686] info: downloading component 'clippy'
[23:22:52.737] info: downloading component 'rust-docs'
[23:22:52.956] info: downloading component 'rust-std'
[23:22:53.318] info: downloading component 'rustc'
[23:22:54.182] info: downloading component 'rustfmt'
[23:22:54.215] info: installing component 'cargo'
[23:22:54.893] info: installing component 'clippy'
[23:22:55.216] info: installing component 'rust-docs'
[23:22:57.620] info: installing component 'rust-std'
[23:23:00.391] info: installing component 'rustc'
[23:23:06.041] info: installing component 'rustfmt'
[23:23:06.533] info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
[23:23:06.533] 
[23:23:06.546]   stable-x86_64-unknown-linux-gnu installed - rustc 1.68.2 (9eb3afe9e 2023-03-27)
[23:23:06.546] 
[23:23:06.546] 
[23:23:06.546] Rust is installed now. Great!
[23:23:06.546] 
[23:23:06.546] To get started you may need to restart your current shell.
[23:23:06.546] This would reload your PATH environment variable to include
[23:23:06.547] Cargo's bin directory ($HOME/.cargo/bin).
[23:23:06.547] 
[23:23:06.547] To configure your current shell, run:
[23:23:06.547] source "$HOME/.cargo/env"
[23:26:44.478] info: downloading installer
[23:26:44.586] error: $HOME differs from euid-obtained home directory: you may be using sudo
[23:26:44.587] error: $HOME directory: /vercel
[23:26:44.587] error: euid-obtained home directory: /root
[23:26:44.618] info: profile set to 'default'
[23:26:44.618] info: default host triple is x86_64-unknown-linux-gnu
[23:26:44.618] warning: Updating existing toolchain, profile choice will be ignored
[23:26:44.690] info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
[23:26:44.709] info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
[23:26:44.710] 
[23:26:44.724]   stable-x86_64-unknown-linux-gnu unchanged - rustc 1.68.2 (9eb3afe9e 2023-03-27)
[23:26:44.724] 
[23:26:44.724] 
[23:26:44.724] Rust is installed now. Great!
[23:26:44.725] 
[23:26:44.725] To get started you may need to restart your current shell.
[23:26:44.726] This would reload your PATH environment variable to include
[23:26:44.726] Cargo's bin directory ($HOME/.cargo/bin).
[23:26:44.726] 
[23:26:44.726] To configure your current shell, run:
[23:26:44.726] source "$HOME/.cargo/env"
[23:26:55.930] Build Completed in /vercel/output [4m]
[23:27:00.673] Generated build outputs:
[23:27:00.673]  - Static files: 9
[23:27:00.673]  - Prerenders: 0
[23:27:00.673]  - Serverless Functions: 4
[23:27:00.674]  - Edge Functions: 0
[23:27:00.674] Serverless regions: Dublin, Ireland
[23:27:00.674] Deployed outputs in 4s
[23:27:01.042] Build completed

arnarthor avatar Mar 31 '23 23:03 arnarthor

Looking at this code https://github.com/vercel-community/rust/blob/main/src/index.ts#L110-L116

I'm wondering if it's just missing a cache key for the $HOME/.cargo folder as well?

arnarthor avatar Mar 31 '23 23:03 arnarthor

I am seeing the same problem. Although my build gets stuck at:

[23:26:44.726] 
[23:26:44.726] To configure your current shell, run:
[23:26:44.726] source "$HOME/.cargo/env"

and does not recover.

callebstrom avatar Apr 01 '23 16:04 callebstrom

I guess one issue with this fix is that there is no notion of $HOME on the vercel build agents right? I have a memory of running into trouble when trying to cache things from $HOME previously. Might be worth trying this out in a branch though and test it in your build. I might give it a shot later tonight.

callebstrom avatar Apr 01 '23 16:04 callebstrom

It also seems to be downloading the toolchain twice.

This should not happen. What's the output when setting VERCEL_BUILDER_DEBUG to true in your project env vars?

I'm running the latest beta and it seems to download the toolchain on each commit.

I am aware of this, but descoped it from the initial rework as unfortunately the solution is not as simple as specifying $HOME/.cargo.

  1. The .cargo dir must be in workPath (or at least moved from/to home during prepareCache and build steps) - Cache Lifecycle

  2. Toolchain configurations may be overwritten - See Overrides

  3. Not everything should be cached - See rust-cache

ecklf avatar Apr 05 '23 09:04 ecklf