Skip to content

Commit 61d9339

Browse files
authored
Remove snforge init and bump MINIMAL_SCARB_VERSION to 2.10.0 (#3562)
- Closes #3725 ## Introduced changes <!-- A brief description of the changes --> - Remove the depracated command `snforge init` ## Checklist <!-- Make sure all of these are complete --> - [ ] Linked relevant issue - [x] Updated relevant documentation - [ ] Added relevant tests - [x] Performed self-review of the code - [x] Added changes to `CHANGELOG.md`
1 parent 1017bac commit 61d9339

File tree

13 files changed

+26
-196
lines changed

13 files changed

+26
-196
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,9 @@ jobs:
142142

143143
- uses: software-mansion/setup-scarb@v1
144144
with:
145-
scarb-version: "2.9.1"
145+
scarb-version: "2.10.0"
146146

147-
- run: cargo test --package forge --features scarb_2_9_1 --test main e2e::requirements::test_warning_on_scarb_version_below_recommended
148-
- run: cargo test --package forge --features scarb_2_9_1 --lib compatibility_check::tests::warning_requirements
149-
- run: cargo test --package forge --features scarb_2_9_1 --test main e2e::running::sierra_gas_with_older_scarb
150-
- run: cargo test --package forge --features scarb_2_9_1 --test main e2e::new::init_new_project_from_scarb_with_snforge_std_deprecated
147+
- run: cargo test --package forge --features scarb_2_10_0 --test main e2e::requirements::test_warning_on_scarb_version_below_recommended
151148

152149
# TODO(#3212): Closures in Cairo are fully supported since version 2.11
153150
test-interact-with-state:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Forge
1111

12+
#### Changed
13+
14+
- Minimal supported `Scarb` version is now `2.10.0` (updated from `2.9.1`)
15+
1216
#### Removed
1317

1418
- Possibility to use `#[available_gas]` with unnamed argument. Use named arguments instead, e.g. `#[available_gas(l2_gas: 5)]`.
19+
- The deprecated command `snforge init`. Use `snforge new` to initialize new `Forge` projects
1520

1621
## [0.49.0] - 2025-09-03
1722

crates/forge/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition.workspace = true
77

88
[features]
99
smoke = []
10-
scarb_2_9_1 = []
10+
scarb_2_10_0 = []
1111
no_scarb_installed = []
1212
debugging = []
1313
assert_non_exact_gas = ["test_utils/assert_non_exact_gas"]

crates/forge/src/compatibility_check.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ mod tests {
223223
}
224224

225225
#[test]
226-
#[cfg_attr(not(feature = "scarb_2_9_1"), ignore)]
227226
fn warning_requirements() {
228227
let mut requirements_checker = RequirementsChecker::new(true);
229228
requirements_checker.add_requirement(Requirement {

crates/forge/src/init.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

crates/forge/src/lib.rs

Lines changed: 15 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use semver::Version;
1515
use shared::auto_completions::{Completions, generate_completions};
1616
use std::cell::RefCell;
1717
use std::ffi::OsString;
18-
use std::process::Command;
1918
use std::sync::Arc;
2019
use std::{fs, num::NonZeroU32, thread::available_parallelism};
2120
use tokio::runtime::Builder;
@@ -25,7 +24,6 @@ pub mod block_number_map;
2524
mod clean;
2625
mod combine_configs;
2726
mod compatibility_check;
28-
mod init;
2927
mod new;
3028
mod profile_validation;
3129
pub mod run_tests;
@@ -36,12 +34,9 @@ mod warn;
3634

3735
pub const CAIRO_EDITION: &str = "2024_07";
3836

39-
const MINIMAL_RUST_VERSION: Version = Version::new(1, 87, 0);
40-
const MINIMAL_SCARB_VERSION: Version = Version::new(2, 9, 1);
41-
const MINIMAL_RECOMMENDED_SCARB_VERSION: Version = Version::new(2, 10, 0);
42-
const MINIMAL_SCARB_VERSION_PREBUILT_PLUGIN: Version = Version::new(2, 10, 0);
37+
const MINIMAL_SCARB_VERSION: Version = Version::new(2, 10, 0);
38+
const MINIMAL_RECOMMENDED_SCARB_VERSION: Version = Version::new(2, 10, 1);
4339
const MINIMAL_USC_VERSION: Version = Version::new(2, 0, 0);
44-
const MINIMAL_SCARB_VERSION_FOR_SIERRA_GAS: Version = Version::new(2, 10, 0);
4540
// TODO(#3723) Bump `MINIMAL_SNFORGE_STD_VERSION` to 0.50.0 and `MINIMAL_SNFORGE_STD_DEPRECATED_VERSION` to 0.50.0
4641
const MINIMAL_SNFORGE_STD_VERSION: Version = Version::new(0, 48, 0);
4742
const MINIMAL_SNFORGE_STD_DEPRECATED_VERSION: Version = Version::new(0, 48, 0);
@@ -91,11 +86,6 @@ enum ForgeSubcommand {
9186
#[command(flatten)]
9287
args: TestArgs,
9388
},
94-
/// Create a new directory with a Forge project
95-
Init {
96-
/// Name of a new project
97-
name: String,
98-
},
9989
/// Create a new Forge project at <PATH>
10090
New {
10191
#[command(flatten)]
@@ -278,10 +268,6 @@ pub fn main_execution(ui: Arc<UI>) -> Result<ExitStatus> {
278268
let cli = Cli::parse();
279269

280270
match cli.subcommand {
281-
ForgeSubcommand::Init { name } => {
282-
init::init(name.as_str(), &ui)?;
283-
Ok(ExitStatus::Success)
284-
}
285271
ForgeSubcommand::New { args } => {
286272
new::new(args)?;
287273
Ok(ExitStatus::Success)
@@ -302,7 +288,7 @@ pub fn main_execution(ui: Arc<UI>) -> Result<ExitStatus> {
302288
Ok(ExitStatus::Success)
303289
}
304290
ForgeSubcommand::Test { args } => {
305-
check_requirements(false, args.tracked_resource, &ui)?;
291+
check_requirements(false, &ui)?;
306292
let cores = if let Ok(available_cores) = available_parallelism() {
307293
available_cores.get()
308294
} else {
@@ -318,7 +304,7 @@ pub fn main_execution(ui: Arc<UI>) -> Result<ExitStatus> {
318304
rt.block_on(run_for_workspace(args, ui))
319305
}
320306
ForgeSubcommand::CheckRequirements => {
321-
check_requirements(true, ForgeTrackedResource::default(), &ui)?;
307+
check_requirements(true, &ui)?;
322308
Ok(ExitStatus::Success)
323309
}
324310
ForgeSubcommand::Completions(completions) => {
@@ -339,41 +325,18 @@ pub fn main_execution(ui: Arc<UI>) -> Result<ExitStatus> {
339325
}
340326
}
341327

342-
fn check_requirements(
343-
output_on_success: bool,
344-
forge_tracked_resource: ForgeTrackedResource,
345-
ui: &UI,
346-
) -> Result<()> {
328+
fn check_requirements(output_on_success: bool, ui: &UI) -> Result<()> {
347329
let mut requirements_checker = RequirementsChecker::new(output_on_success);
348-
match forge_tracked_resource {
349-
ForgeTrackedResource::CairoSteps => {
350-
requirements_checker.add_requirement(Requirement {
351-
name: "Scarb".to_string(),
352-
command: RefCell::new(ScarbCommand::new().arg("--version").command()),
353-
minimal_version: MINIMAL_SCARB_VERSION,
354-
minimal_recommended_version: Some(MINIMAL_RECOMMENDED_SCARB_VERSION),
355-
helper_text:
356-
"Follow instructions from https://docs.swmansion.com/scarb/download.html"
357-
.to_string(),
358-
version_parser: create_version_parser(
359-
"Scarb",
360-
r"scarb (?<version>[0-9]+.[0-9]+.[0-9]+)",
361-
),
362-
});
363-
}
364-
ForgeTrackedResource::SierraGas => {
365-
requirements_checker.add_requirement(Requirement {
366-
name: "Scarb".to_string(),
367-
command: RefCell::new(ScarbCommand::new().arg("--version").command()),
368-
minimal_version: MINIMAL_SCARB_VERSION_FOR_SIERRA_GAS,
369-
minimal_recommended_version: None,
370-
helper_text: format!("To track sierra gas, minimal required scarb version is {MINIMAL_SCARB_VERSION_FOR_SIERRA_GAS} \
371-
(it comes with sierra >= 1.7.0 support)\n\
372-
Follow instructions from https://docs.swmansion.com/scarb/download.html"),
373-
version_parser: create_version_parser("Scarb", r"scarb (?<version>[0-9]+.[0-9]+.[0-9]+)"),
374-
});
375-
}
376-
}
330+
requirements_checker.add_requirement(Requirement {
331+
name: "Scarb".to_string(),
332+
command: RefCell::new(ScarbCommand::new().arg("--version").command()),
333+
minimal_version: MINIMAL_SCARB_VERSION,
334+
minimal_recommended_version: Some(MINIMAL_RECOMMENDED_SCARB_VERSION),
335+
helper_text: "Follow instructions from https://docs.swmansion.com/scarb/download.html"
336+
.to_string(),
337+
version_parser: create_version_parser("Scarb", r"scarb (?<version>[0-9]+.[0-9]+.[0-9]+)"),
338+
});
339+
377340
requirements_checker.add_requirement(Requirement {
378341
name: "Universal Sierra Compiler".to_string(),
379342
command: RefCell::new(UniversalSierraCompilerCommand::new().arg("--version").command()),
@@ -387,28 +350,5 @@ fn check_requirements(
387350
});
388351
requirements_checker.check(ui)?;
389352

390-
let scarb_version = ScarbCommand::version().run()?.scarb;
391-
if scarb_version < MINIMAL_SCARB_VERSION_PREBUILT_PLUGIN {
392-
let mut requirements_checker = RequirementsChecker::new(output_on_success);
393-
requirements_checker.add_requirement(Requirement {
394-
name: "Rust".to_string(),
395-
command: RefCell::new({
396-
let mut cmd = Command::new("rustc");
397-
cmd.arg("--version");
398-
cmd
399-
}),
400-
minimal_version: MINIMAL_RUST_VERSION,
401-
minimal_recommended_version: None,
402-
version_parser: create_version_parser(
403-
"Rust",
404-
r"rustc (?<version>[0-9]+.[0-9]+.[0-9]+)",
405-
),
406-
helper_text: "Follow instructions from https://www.rust-lang.org/tools/install"
407-
.to_string(),
408-
});
409-
410-
requirements_checker.check(ui)?;
411-
}
412-
413353
Ok(())
414354
}

crates/forge/tests/e2e/new.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,6 @@ use toml_edit::{DocumentMut, Formatted, InlineTable, Item, Value};
2525

2626
static RE_NEWLINES: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\n{3,}").unwrap());
2727

28-
#[test]
29-
fn init_new_project() {
30-
let temp = tempdir_with_tool_versions().unwrap();
31-
32-
let output = runner(&temp)
33-
.args(["init", "test_name"])
34-
.env("DEV_DISABLE_SNFORGE_STD_DEPENDENCY", "true")
35-
.assert()
36-
.success();
37-
38-
assert_stdout_contains(
39-
output,
40-
indoc!(
41-
r"
42-
[WARNING] Command `snforge init` is deprecated and will be removed in the future. Please use `snforge new` instead.
43-
"
44-
),
45-
);
46-
47-
validate_init(&temp.join("test_name"), false, &Template::BalanceContract);
48-
}
49-
5028
#[test_case(&Template::CairoProgram; "cairo-program")]
5129
#[test_case(&Template::BalanceContract; "balance-contract")]
5230
#[test_case(&Template::Erc20Contract; "erc20-contract")]
@@ -130,29 +108,6 @@ fn init_new_project_from_scarb() {
130108
validate_init(&temp.join("test_name"), true, &Template::BalanceContract);
131109
}
132110

133-
#[test]
134-
#[cfg_attr(not(feature = "scarb_2_9_1"), ignore)]
135-
fn init_new_project_from_scarb_with_snforge_std_deprecated() {
136-
let temp = tempdir_with_tool_versions().unwrap();
137-
let tool_version_path = temp.join(".tool-versions");
138-
fs::write(tool_version_path, "scarb 2.11.4").unwrap();
139-
140-
SnapboxCommand::from_std(
141-
ScarbCommand::new()
142-
.current_dir(temp.path())
143-
.args(["new", "test_name"])
144-
.env("SCARB_INIT_TEST_RUNNER", "starknet-foundry")
145-
.env(
146-
"PATH",
147-
append_to_path_var(snforge_test_bin_path().parent().unwrap()),
148-
)
149-
.command(),
150-
)
151-
.assert()
152-
.success();
153-
154-
validate_init(&temp.join("test_name"), true, &Template::BalanceContract);
155-
}
156111
pub fn append_to_path_var(path: &Path) -> OsString {
157112
let script_path = iter::once(path.to_path_buf());
158113
let os_path = env::var_os("PATH").unwrap();

crates/forge/tests/e2e/requirements.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn happy_path() {
3434
}
3535

3636
#[test]
37-
#[cfg_attr(not(feature = "scarb_2_9_1"), ignore)]
37+
#[cfg_attr(not(feature = "scarb_2_10_0"), ignore)]
3838
fn test_warning_on_scarb_version_below_recommended() {
3939
let temp = setup_package("simple_package");
4040
let output = runner(&temp).arg("check-requirements").assert();
@@ -44,8 +44,7 @@ fn test_warning_on_scarb_version_below_recommended() {
4444
indoc! {r"
4545
Checking requirements
4646
47-
✅ Rust [..]
48-
⚠️ Scarb Version 2.9.1 doesn't satisfy minimal recommended [..]
47+
⚠️ Scarb Version 2.10.0 doesn't satisfy minimal recommended [..]
4948
✅ Universal Sierra Compiler [..]
5049
"},
5150
);

crates/forge/tests/e2e/running.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,30 +1107,6 @@ fn call_nonexistent_selector() {
11071107
);
11081108
}
11091109

1110-
#[test]
1111-
#[cfg_attr(not(feature = "scarb_2_9_1"), ignore)]
1112-
fn sierra_gas_with_older_scarb() {
1113-
let temp = setup_package("erc20_package");
1114-
let output = test_runner(&temp)
1115-
.arg("--detailed-resources")
1116-
.arg("--tracked-resource")
1117-
.arg("sierra-gas")
1118-
.assert()
1119-
.failure();
1120-
1121-
assert_stdout_contains(
1122-
output,
1123-
indoc! {r"
1124-
Checking requirements
1125-
[..]Scarb Version [..] doesn't satisfy minimal 2.10.0[..]
1126-
[..]To track sierra gas, minimal required scarb version is 2.10.0 (it comes with sierra >= 1.7.0 support)[..]
1127-
[..]Follow instructions from https://docs.swmansion.com/scarb/download.html[..]
1128-
[..]
1129-
[ERROR] Requirements not satisfied
1130-
"},
1131-
);
1132-
}
1133-
11341110
#[test]
11351111
fn exact_printing_pass() {
11361112
let temp = setup_package("deterministic_output");

docs/src/SUMMARY.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272

7373
* [`snforge` Commands](appendix/snforge.md)
7474
* [test](appendix/snforge/test.md)
75-
* [init](appendix/snforge/init.md)
7675
* [new](appendix/snforge/new.md)
7776
* [clean](appendix/snforge/clean.md)
7877
* [clean-cache](appendix/snforge/clean-cache.md)

0 commit comments

Comments
 (0)