4

I am trying to run the frontier-node-template:https://github.com/substrate-developer-hub/frontier-node-template/
But it gives an error as shown below. I tried to change the
rustup default nightly-2021-11-12
rustup override set nightly-2021-11-12
rustup target add wasm32-unknown-unknown --toolchain nightly-2021-11-12

error[E0308]: mismatched types                                                                                                                                                         
   --> C:\Users\msi\.cargo\registry\src\github.com-1ecc6299db9ec823\parity-db-0.3.1\src\index.rs:502:3
    |
501 |     fn madvise_random(&self, _map: &mut memmap2::MmapMut) {
    |                                                           - expected `()` because of default return type
502 |         Ok(())
    |         ^^^^^^- help: consider using a semicolon here: `;`
    |         |
    |         expected `()`, found enum `std::result::Result`
    |
    = note: expected unit type `()`
                    found enum `std::result::Result<(), _>`

   Compiling cid v0.6.1
   Compiling zstd v0.6.1+zstd.1.4.9
For more information about this error, try `rustc --explain E0308`.                                                                                                                    
error: could not compile `parity-db` due to previous error                                                                                                                             
warning: build failed, waiting for other jobs to finish...
4
  • 1
    I can't personally repro: cargo check works for me on rust 2021-11-12 nightly and 2021-12-12 nightly. That said I had to have protobuf's compiler protoc on the path as one of the dependencies seems to need that. Also I am using nixos / linux. cargo build --release --all-targets also worked for me on linux.
    – Squirrel
    Commented Mar 29, 2022 at 20:20
  • Which OS you are using?
    – Pankaj
    Commented Mar 30, 2022 at 3:29
  • C:\Users\ gives away the OS :-)
    – Squirrel
    Commented Mar 30, 2022 at 15:17
  • 2
    I would really recommend WSL2 if it's at all possible (ubuntu).
    – Squirrel
    Commented Mar 30, 2022 at 15:18

1 Answer 1

8

This error normally comes in windows. As Native development of substrate is not very well supported in windows so you will face errors now and then. But there is a permanent solution for the same. As we all know Substrate development is easiest on Unix-based operating systems like macOS or Linux. So we will convert our windows into Linux without installing any new software just by Enabling some inbuilt windows feature.

First of all, prepare your windows system for the substrate. This can be done using windows subsystem Linux(wsl). To use it go into the control panel > programs > programs and Features > Turn windows Feature On or OFF, And in it tick mark on Hyper-V and windows subsystem for Linux as shown in the images below.

enter image description here

enter image description here

After that Enable the virtualization by going into the bios advance section on your laptop. To access bios on different laptops there is a different process. So look on youtube for how to Enable virtualization on your system.

If you have a home edition of windows, Hyper-V might not be there so first install that. To install hyper-v follow the below instruction:

  1. Open Notepad and paste the below-given code as shown below:
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hv.txt
for /f %%i in ('findstr /i . hv.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hv.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause
  1. After that in the notepad where you have pasted the code select 'Save as' and then name the file as hyper-v.bat and below that in 'save as type' select All Files and save it on the desktop or wherever you can easily find it.
  2. Then run that file as administrator

It will ask you to restart your system and Hyper-v will be installed on your system.

After all the above is done go into the windows app store and search wsl. You will se multiple options. There select Ubuntu 20.04.4 LTS (or whatever you like) and download it as it's famous and normally used. And in ubuntu set username and password. Username should follow [a-z,0-9] only.

After that follow the instructions on this doc: https://docs.substrate.io/v3/getting-started/installation/#ubuntudebian

1
  • 1
    virtualbox and/or vagrant fit the bill too.
    – Geneidy
    Commented Apr 4, 2022 at 20:49

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