shramee / starklings-cairo1

An interactive tutorial to get you up and running with Cairo v1 and Starknet
MIT License
450 stars 394 forks source link

Unable to compile Starklings for any combination of Rustc, Scarb, Cairo lang versions #216

Closed stranger80 closed 1 month ago

stranger80 commented 2 months ago

Hi, It seems that Starklings are not possible to compile anymore, due to various combination of errors & dependency hell. Some symptoms observed:

1) Rustc 1.76.0, starklings/Cairo.toml unchanged

Error on build:

   Compiling scarb v2.6.3 (https://github.com/software-mansion/scarb?tag=v2.6.3#e6f921df)
error[E0061]: this function takes 2 arguments but 1 argument was supplied
  --> /home/mbarwicki/.cargo/git/checkouts/scarb-831c32bf23da0a7c/e6f921d/scarb/src/ops/scripts.rs:27:21
   |
27 |               Rc::new(ExecutableCommand::new(
   |  _____________________^^^^^^^^^^^^^^^^^^^^^^-
28 | |                 ws.config().app_exe()?.display().to_string(),
29 | |             )) as Rc<dyn ShellCommand>,
   | |_____________- an argument of type `PathBuf` is missing
   |
note: associated function defined here
  --> /home/mbarwicki/.cargo/registry/src/index.crates.io-6f17d22bba15001f/deno_task_shell-0.18.0/src/shell/commands/executable.rs:19:10
   |
19 |   pub fn new(display_name: String, command_path: PathBuf) -> Self {
   |          ^^^
help: provide the argument
   |
27 |             Rc::new(ExecutableCommand::new(ws.config().app_exe()?.display().to_string(), /* PathBuf */)) as Rc<dyn ShellCommand>,
   |                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0061`.
error: could not compile `scarb` (lib) due to 1 previous error

Reason: Scarb v2..3 references deno_task_shell crate >0.13, while the crate has non-backwards compatibe change added in 0.16: https://docs.rs/deno_task_shell/0.16.0/deno_task_shell/struct.ExecutableCommand.html

2) Rustc 1.76.0, starklings/Cairo.toml amended to refer to latest Scarb

# Cargo.toml
...
# Cairo runner dependencies
cairo-lang-test-runner = "2.8.0"
cairo-lang-test-plugin = "2.8.0"
cairo-lang-runner = "2.8.0"
cairo-lang-sierra = "2.8.0"
scarb = { git = "https://github.com/software-mansion/scarb", tag = "v2.8.1" }
scarb-ui = { git = "https://github.com/software-mansion/scarb", tag = "v2.8.1" }

Error on build:

error: package `ra_ap_toolchain v0.0.218` cannot be built because it requires rustc 1.78 or newer, while the currently active rustc version is 1.76.0
Either upgrade to rustc 1.78 or newer, or use
cargo update ra_ap_toolchain@0.0.218 --precise ver
where `ver` is the latest version of `ra_ap_toolchain` supporting rustc 1.76.0

3) Rustc 1.78.0, starklings/Cairo.toml amended to refer to latest Scarb

# Cargo.toml
...
# Cairo runner dependencies
cairo-lang-test-runner = "2.8.0"
cairo-lang-test-plugin = "2.8.0"
cairo-lang-runner = "2.8.0"
cairo-lang-sierra = "2.8.0"
scarb = { git = "https://github.com/software-mansion/scarb", tag = "v2.8.1" }
scarb-ui = { git = "https://github.com/software-mansion/scarb", tag = "v2.8.1" }

Error on build:

...
error[E0658]: use of unstable library feature 'lazy_cell'
 --> /home/mbarwicki/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cairo-lang-sierra-2.8.0/src/extensions/modules/circuit.rs:2:5
  |
2 | use std::sync::LazyLock;
  |     ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #109736 <https://github.com/rust-lang/rust/issues/109736> for more information
...

4) Rustc 1.80.0, starklings/Cairo.toml amended to refer to latest Scarb

# Cargo.toml
...
# Cairo runner dependencies
cairo-lang-test-runner = "2.8.0"
cairo-lang-test-plugin = "2.8.0"
cairo-lang-runner = "2.8.0"
cairo-lang-sierra = "2.8.0"
scarb = { git = "https://github.com/software-mansion/scarb", tag = "v2.8.1" }
scarb-ui = { git = "https://github.com/software-mansion/scarb", tag = "v2.8.1" }

Errors on build:

error[E0063]: missing field `features` in initializer of `MetadataOptions`
  --> src/scarb.rs:64:10
   |
64 |         &MetadataOptions {
   |          ^^^^^^^^^^^^^^^ missing `features`

error[E0063]: missing field `features` in initializer of `MetadataOptions`
   --> src/scarb.rs:150:10
    |
150 |         &MetadataOptions {
    |          ^^^^^^^^^^^^^^^ missing `features`

error[E0063]: missing fields `gas_enabled` and `print_resource_usage` in initializer of `TestRunConfig`
   --> src/scarb.rs:186:26
    |
186 |             let config = TestRunConfig {
    |                          ^^^^^^^^^^^^^ missing `gas_enabled` and `print_resource_usage`

error[E0560]: struct `CompileOpts` has no field named `include_targets`
   --> src/scarb.rs:213:13
    |
213 |             include_targets: vec![],
    |             ^^^^^^^^^^^^^^^ unknown field
    |
help: a field with a similar name exists
    |
213 |             include_target_kinds: vec![],
    |             ~~~~~~~~~~~~~~~~~~~~

error[E0560]: struct `CompileOpts` has no field named `exclude_targets`
   --> src/scarb.rs:214:13
    |
214 |             exclude_targets: vec![TargetKind::TEST],
    |             ^^^^^^^^^^^^^^^ unknown field
    |
help: a field with a similar name exists
    |
214 |             exclude_target_kinds: vec![TargetKind::TEST],
    |             ~~~~~~~~~~~~~~~~~~~~

error[E0560]: struct `CompileOpts` has no field named `include_targets`
   --> src/scarb.rs:217:13
    |
217 |             include_targets: vec![TargetKind::TEST],
    |             ^^^^^^^^^^^^^^^ unknown field
    |
help: a field with a similar name exists
    |
217 |             include_target_kinds: vec![TargetKind::TEST],
    |             ~~~~~~~~~~~~~~~~~~~~

error[E0560]: struct `CompileOpts` has no field named `exclude_targets`
   --> src/scarb.rs:218:13
    |
218 |             exclude_targets: vec![],
    |             ^^^^^^^^^^^^^^^ unknown field
    |
help: a field with a similar name exists
    |
218 |             exclude_target_kinds: vec![],
    |             ~~~~~~~~~~~~~~~~~~~~

Some errors have detailed explanations: E0063, E0560.

Conclusion: It feels the best way to go at this point is to update Starklings code to take into account all the breaking updates in the referred Scarb "ops" code. Is this something you are willing to take forward as at the moment there is no simple way of using Starklings, which used to be an awsome learning resource?