shuttle icon indicating copy to clipboard operation
shuttle copied to clipboard

Support import of own crate in main.rs

Open jacobsvante opened this issue 3 years ago • 0 comments

Thank you for releasing 0.4 which no longer requires crate-type = ["cdylib"], this is great!

Another thing I would like to see is the ability to import the own crate in main.rs, but it seems that one can no longer use cargo shuttle run or cargo shuttle deploy after doing that.

MRE / Minimal reproducible example:

cargo install [email protected]
git clone [email protected]:shuttle-hq/shuttle.git
cd shuttle/examples/axum/hello-world
echo 'pub fn say_hi() { println!("hi"); }' >> src/lib.rs
echo 'use hello_world::say_hi; fn main() { say_hi(); }' > src/main.rs
cargo shuttle run

The last command gives the following output for me:

    Building /Users/jacob/Downloads/shuttle/examples/axum/hello-world
   Compiling hello-world v0.1.0 (/Users/jacob/Downloads/shuttle/examples/axum/hello-world)
error[E0432]: unresolved import `hello_world`
 --> src/main.rs:1:5
  |
1 | use hello_world::say_hi; fn main() { say_hi(); }
  |     ^^^^^^^^^^^ use of undeclared crate or module `hello_world`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `hello-world` due to previous error
Error: 1 job failed

Now why do I want a main file? Easy - I want it to provide an app-specific CLI which I use during development.

jacobsvante avatar Jul 14 '22 13:07 jacobsvante