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

update README to clarify the built file should be ran from the root folder. #52

Open
NicTanghe opened this issue Oct 1, 2024 · 8 comments

Comments

@NicTanghe
Copy link

NicTanghe commented Oct 1, 2024

When building the template with the release tag,

the site is generated but pressing the increment button doesn`t work.

When more complexity is added to the site it also doesn`t work.

I`ll attach a file with system info.

bugreport.txt

@gbj
Copy link
Contributor

gbj commented Oct 1, 2024

I tried to reproduce the bug based on the information provided, following these steps:

  • cargo leptos new --git leptos-rs/start-axum
  • cd {name of the project}
  • cargo leptos serve --release

The button works fine.

Could you please clarify with the steps you took to build and serve the application that led to the issue?

Thanks.

@NicTanghe
Copy link
Author

NicTanghe commented Oct 1, 2024

Ok here`s what i ran.
(using build instead of serve)

cargo leptos new --git leptos-rs/start-axum
cd {name of the project}
cargo leptos build --release

cd target/release
./{name of the project}

@gbj
Copy link
Contributor

gbj commented Oct 1, 2024

When I follow your steps, I get 404s in the browser console for the JS, WASM, and CSS files, and Errors: [ NotFound ] logged three times in the terminal, one for each 404.

I then cd ../.. and run target/release/sax3 so that the root of the project is the current working directory. Reload and the page works.

This is because the static file server (which is included in the app, it lives in user code that you control) uses paths relative to the current working directory — when you run the binary from target/release it is looking for files in the wrong place.

@NicTanghe
Copy link
Author

NicTanghe commented Oct 2, 2024

Oh, that makes total sense.
Could you be so kind to add that to the README so that an its obvious to the oblivious.

@NicTanghe NicTanghe changed the title Increment button doesnt function when build with --release tag update README to clarify the build file should be ran from the root folder. Oct 2, 2024
@NicTanghe NicTanghe changed the title update README to clarify the build file should be ran from the root folder. update README to clarify the built file should be ran from the root folder. Oct 2, 2024
@NicTanghe
Copy link
Author

Or preferably change it so that it doesn't search for the files from the directory its ran but searches for them relative to its location on disc ?
Or does that break certain common deployments ?

@gbj
Copy link
Contributor

gbj commented Oct 2, 2024

I think it's pretty important to clarify that the code that does this is entirely under your control, in fileserv.rs. You can make whatever changes to it you want. It is just some plain Axum static server code.

The template works as described in the README, which includes instructions on how to run it with or without cargo-leptos. Note that the instructions for running it without cargo-leptos explicitly say that you should have your site folder as a sibling of the binary.

@NicTanghe
Copy link
Author

ok i c that All I`m saying is that it wasn't immediately obvious having read the README that that was how it worked and I thought it would improve the docs.

@NicTanghe
Copy link
Author

NicTanghe commented Oct 3, 2024

Looking trough the code at fileserve.rs leads to

site_root: String

The path of the all the files generated by cargo-leptos. This defaults to ‘.’ for convenience when integrating with other tools.

Which isn’t in and of itself even that clear, relative to what that "." Is.

I really think the documentation could benefit from some further clarification on all this.

I will make a branch and clarify, although I think you be better suited to comment the code aswell.

ps.
It does indeed state that you should have your site folder as a sibling of the binary which I also tried to do as I understood it, and then it also failed to execute.
( here is assumed that site refers to release ?)

pss.
Thanks for all the help you have already provided me, I'm not trying to be a dick, I'm trying to improve the amazing proj. And things seem obvious quite fast when you know something trough and trough, but really they aren't when you are new, and that's who the README is for.

Psss.
take your time look around do more important things first.

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

2 participants