2

I am trying to following the tutorials at substrate.dev and I am getting stuck on this one. Specifically, when I add this code to my runtime/src/lib.rs file:

impl pallet_scheduler::Config for Runtime {
  type Event = Event;
  type Origin = Origin;
  type PalletsOrigin = OriginCaller;
  type Call = Call;
  type MaximumWeight = MaximumSchedulerWeight;
  type ScheduleOrigin = frame_system::EnsureRoot<AccountId>;
  type MaxScheduledPerBlock = MaxScheduledPerBlock;
  type WeightInfo = ();
  type OriginPrivilegeCmp = EqualPrivilegeOnly;
  type PreimageProvider = ();
  type NoPreimagePostponement = ();
}

I get this error when I try to build:

--- stderr
     Compiling node-template-runtime v4.0.0-dev (/home/bosr/rust/substrate-node-template/runtime)
  error[E0433]: failed to resolve: use of undeclared crate or module `pallet_scheduler`
     --> /home/bosr/rust/substrate-node-template/runtime/src/lib.rs:151:6
      |
  151 | impl pallet_scheduler::Config for Runtime {
      |      ^^^^^^^^^^^^^^^^ use of undeclared crate or module `pallet_scheduler`

I do have this line in the [dependencies] section:

pallet-scheduler = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }

and the version and branch match the rest of the dependencies.

4
  • Try importing it <use pallet_scheduler> Commented Sep 22, 2022 at 20:36
  • If I do that I get an unresolved import pallet_scheduler error ``` --- stderr Compiling node-template-runtime v4.0.0-dev (/home/bosr/rust/substrate-node-template/runtime) error[E0432]: unresolved import pallet_scheduler --> /home/bosr/rust/substrate-node-template/runtime/src/lib.rs:9:5 | 9 | use pallet_scheduler; | ^^^^^^^^^^^^^^^^ no external crate pallet_scheduler ``` Commented Sep 22, 2022 at 20:58
  • Does it work if you remove the '.git' at the end of the Substrate URL in your Cargo.toml? Also, this line must be in the Cargo.toml file for the runtime crate, not any other Cargo.toml file.
    – rob
    Commented Sep 23, 2022 at 5:21
  • No, that didn't make a difference. All the other dependencies end in .git as well. Yes, I am using Cargo.toml and that is the only toml file I have. Commented Sep 23, 2022 at 13:08

1 Answer 1

1

The issue here is probably you added your dependency in the [dev-dependencies] section rather than directly in the [dependencies] section of the Cargo.toml file.

This will cause the crate to only be included when running tests. If this is not correct, then please share the full Cargo.toml file you edited.

https://doc.rust-lang.org/rust-by-example/testing/dev_dependencies.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.