fermyon / feedback

Centralized repository for Fermyon Cloud feedback and bug reports
3 stars 1 forks source link

Custom $env:CARGO_TARGET_DIR not supported by spin cli #53

Closed PeterMHammond closed 3 months ago

PeterMHammond commented 3 months ago

Describe the bug spin up does not use a custom Cargo build location set in the CARGO_TARGET_DIR environment variable and returns an error. For example, my system was set to use a special build drive:

PS E:\spin\DEMO_AI> $env:CARGO_TARGET_DIR
D:\Rust\cache_directory

Error Example

PS E:\spin\DEMO_AI> spin up --runtime-config-file runtime-config.toml                                                      
Logging component stdio to ".spin\logs\"
Using [llm_compute: remote-http] runtime config from "runtime-config.toml"
Storing default key-value data to ".spin\sqlite_key_value.db"
Error: Failed to instantiate component 'demo-ai'

Caused by:
   0: failed to read component source from disk at path "E:\spin\DEMO_AI\target\wasm32-wasi\release\demo_ai.wasm"
   1: The system cannot find the path specified. (os error 3)

Frequency of the bug Please check one:

Set-up information Please share the version of Spin used when the bug occurred. You can find the version of Spin by running spin -V.

spin -V
spin 2.6.0-pre0 (VERGEN_IDEMPOTENT_OUTPUT VERGEN_IDEMPOTENT_OUTPUT)

To Reproduce Steps to reproduce the behavior:

  1. Windows OS
  2. Using the PowerShell commandline
  3. Set the CARGO_TARGET_DIR to a different directory than the default: $env:CARGO_TARGET_DIR = "D:\Rust\cache_directory"
  4. Run: spin build
  5. See error
    Caused by:
    0: failed to read component source from disk at path "E:\spin\DEMO_AI\target\wasm32-wasi\release\demo_ai.wasm"
    1: The system cannot find the path specified. (os error 3)

Expected behavior spin build, spin up, and spin deploy should use the path from the CARGO_TARGET_DIR, if it has been set.

Screenshots image

Additional context Once I removed the custom variable using: Remove-Item Env:CARGO_TARGET_DIR The spin build, spin up, and spin deploy commands worked as expected.

itowlson commented 3 months ago

Kia ora @PeterMHammond, you can update the path for Spin to find your Wasm file in the [component.xyz] source field of your spin.toml file e.g.

[component.v2vanilla]
source = "target/wasm32-wasi/release/v2vanilla.wasm"  # Change this to point to your output location

The templates generate the default location because the Spin template system is not wise to users' Cargo settings, but it's only an initial generate and you can modify to suit your system.

PeterMHammond commented 3 months ago

Kia ora @PeterMHammond, you can update the path for Spin to find your Wasm file in the [component.xyz] source field of your spin.toml file e.g.

[component.v2vanilla]
source = "target/wasm32-wasi/release/v2vanilla.wasm"  # Change this to point to your output location

The templates generate the default location because the Spin template system is not wise to users' Cargo settings, but it's only an initial generate and you can modify to suit your system.

Thank you for pointing that out. My apologies, as I should have checked into the spin.toml more. I assume it would resolve this issue. I'll close the issue.