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

spin build --up fails because project-name in template wasn't instantiated #12

Open
Boscop opened this issue Jan 18, 2024 · 10 comments
Open

Comments

@Boscop
Copy link

Boscop commented Jan 18, 2024

$ spin build --up
Building component my-leptos-app with `cargo leptos build --release && LEPTOS_OUTPUT_NAME=my_leptos_app cargo build --lib --target wasm32-wasi --release --no-default-features --features ssr`
error: invalid character `{` in package name: `{{project-name | kebab_case}}`, the first character must be a Unicode XID start character (most letters or `_`)
 --> C:\Users\me\scoop\persist\rustup\.cargo\git\checkouts\leptos-spin-8ab45c2d3a8bc267\fe67739\templates\leptos-ssr\content\Cargo.toml:2:8
  |
2 | name = "{{project-name | kebab_case}}"
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
    Finished release [optimized] target(s) in 0.14s
       Cargo finished cargo build --package=my-leptos-app --lib --target-dir=D:\dev\proj\my-leptos-app\target\front --target=wasm32-unknown-unknown --no-default-features --features=hydrate --release
       Front compiling WASM
error: invalid character `{` in package name: `{{project-name | kebab_case}}`, the first character must be a Unicode XID start character (most letters or `_`)
 --> C:\Users\me\scoop\persist\rustup\.cargo\git\checkouts\leptos-spin-8ab45c2d3a8bc267\fe67739\templates\leptos-ssr\content\Cargo.toml:2:8
  |
2 | name = "{{project-name | kebab_case}}"
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
    Finished release [optimized] target(s) in 0.15s
       Cargo finished cargo build --package=my-leptos-app --bin=my-leptos-app --no-default-features --features=ssr --release
'LEPTOS_OUTPUT_NAME' is not recognized as an internal or external command,
operable program or batch file.
Error: Build command for component my-leptos-app failed with status Exited(1)
@itowlson
Copy link
Collaborator

I'm not quite sure what's going on here. It seems like some people are seeing that when Cargo tries to build a Git reference it picks up files that are not part of the crate. @benwis mentioned he saw the message but it didn't prevent the build. And I'm not seeing it at all.

@Boscop Could you share what version of Cargo you're running please?

@dicej @rylev Do you have any idea why this might be happening?

@rylev
Copy link

rylev commented Jan 18, 2024

I think we'll need a more consistent way to reproduce this before being able to say what the root cause is.

@benwis
Copy link
Contributor

benwis commented Jan 18, 2024

I'll try to give more details
Rust: 1.77.0-nightly(latest as of Jan 18)
Spin spin 2.2.0-pre0 (b435f831 1980-01-01)
spin-cloud 0.5.1 (7c32d40 1980-01-01)
Nixos 24.05
Building the repo here:
https://github.com/benwis/benwis_spin
and here's the build log of spin build
build_log.txt

As he said, everything still builds and deploys fine for me, those messages just seem odd. My rudimentary theory is that they're coming from rust itself, and may be an issue with nightly?

@Boscop
Copy link
Author

Boscop commented Jan 18, 2024

For me it's also failing because this syntax of setting env vars doesn't work on windows:

command = "cargo leptos build --release && LEPTOS_OUTPUT_NAME=benwis_spin cargo build --lib --target wasm32-wasi --release --no-default-features --features ssr"

Is there a platform-agnostic way to write this build command?

Or is it possible to remove the need for having this env var in the first place? :)


Btw, I see watch = ["src/**/*.rs", "Cargo.toml"], is this supposed to support hot reload?
I'm asking because it's not hot-reloading when I modify the app.rs file..

@Boscop
Copy link
Author

Boscop commented Jan 18, 2024

Btw, spin up --build worked when I set the env var outside (in cmd.exe) and then removed it from spin.toml.

But calling spin deploy directly afterwards failed:

>spin deploy
Error: Failed to load Spin app from "spin.toml"

Caused by:
    0: Failed to load component `pkg`
    1: Failed to load Wasm source "https://github.com/fermyon/spin-fileserver/releases/download/v0.1.0/spin_static_fs.wasm" with digest "sha256:96c76d9af86420b39eb6cd7be5550e3cb5d4cc4de572ce0fd1f6a29471536cb4"
    2: Error fetching source URL "https://github.com/fermyon/spin-fileserver/releases/download/v0.1.0/spin_static_fs.wasm"
    3: failed to persist temporary file path: The filename, directory name, or volume label syntax is incorrect. (os error 123)
    4: The filename, directory name, or volume label syntax is incorrect. (os error 123)

Learn more at https://developer.fermyon.com/cloud/faq

Could it be that the downloaded file's target path contains chars that are invalid in a windows path?

@itowlson
Copy link
Collaborator

@Boscop Yes, I'm afraid that spin build expression is not portable. This is all still very much in development and I'm sorry for the rough edges. Glad to hear you were able to work around it.

Re the error when deploying from Windows: this was meant to be fixed by fermyon/spin#2159 but the cloud plugin (which spin deploy uses under the hood) might not have updated with that fix yet. I will test and confirm. Sorry for the bumpy experience and thanks for letting us know the problems you're running into.

@itowlson
Copy link
Collaborator

@Boscop I've reproduced your problem - the cloud plugin is using download code from before the Windows fix. I know we've already updated it but not done a release - I will see if we can get one out today.

@itowlson
Copy link
Collaborator

@Boscop cloud deploy fix is out. Please run

spin plugins update
spin plugins upgrade cloud

You should then have cloud plugin 0.6.1 and your Windows deploys should work! Sorry for the inconvenience.

@Boscop
Copy link
Author

Boscop commented Jan 21, 2024

Thanks, it worked :)
Btw, is there a way right now to make the command work in a cross-platform way?

@itowlson
Copy link
Collaborator

Not yet I'm afraid. We've chatted about allowing command to be an array, which would solve the && problem; maybe we need a way to specify environment variables for the build process too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants