How to fix error[E0283] in RUST while installing cargo-generate? - rust

I was trying to run this cargo install command
cargo install cargo-generate --features vendored-openssl
and got this error
error[E0283]: type annotations needed in RUST while installing cargo-generate
How to fix this issue?

This seems to be a problem with updated dependencies. The issue ist tracked here.
You can work around this issue by using the dependencies as they are specified the Cargo.lock file of the current cargo-generate crate version. To do so use this command:
cargo install --locked cargo-generate --features vendored-openssl

Related

Does `cargo install` download binaries compiled on someone else's computer?

Does cargo install download binaries compiled on someone else's computer?
Can it be the case that such pre-builts are sometimes downloaded when executing cargo install?
The output of cargo install suggests that compiling takes place, but I am not sure if I can rely that cargo install will never download anything pre-compiled to my computer.
Thus, whenever I can I manually clone a repo and compile the binaries myself, .e.g.
git clone https://github.com/mitnk/cicada.git && cd cicada && cargo build --release && sudo mv target/release/cicada /usr/local/bin
instead of installing, e.g. cargo install -f cicada. I only do the former because I would like to avoid downloading
binaries compiled on someone else's copmputer? Another reason for this is that I prefer to compile the binaries with --release.
I am not quite sure that such optimization takes place when cargo install is executed.
cargo install downloads and compiles the crate locally, using the same mechanisms as when it builds a crate you have downloaded.
cargo install defaults to release builds. You have to use the --debug flag to build debug builds.
The build scripts of the crates may download pre-compiled binaries. For example, crates that are bindings to C libraries may download the library. But this is true even if you git clone the source as well.

How can I run a command before compiling the packages of the dependencies with `cargo build`?

How do I manipulate Cargo such that it is able to run a set of command or stuff before it starts building each package individually? I want to use Cargo to do something to the source code of each other dependency packages it receives before it builds those dependencies.

Does cargo have an equivalent npm install --save option to automatically add dependencies to Cargo.toml? [duplicate]

I expected there to be something like: cargo install stopwatch but could not find it in the docs.
Finding the package version and manually adding the package to .toml:
[dependencies]
stopwatch="0.0.6"
Does not feel automated enough. :)
No, there is no such thing built in to Cargo. There is only a cargo install subcommand which installs the binaries of a crate system-wide.
New third-party Cargo subcommands can be created, and cargo edit, does what you want.
These cargo subcommands can then be installed by cargo install, in a fun meta circle!
% cargo install cargo-edit
# Now `cargo add` is available
% cargo add mycrate
As of Rust 1.62.0, you can use the following command to add dependencies, avoiding you to open the .toml file.
cargo add dependency#version
More info here: https://doc.rust-lang.org/nightly/cargo/commands/cargo-add.html

How to correctly compile a nodejs package before installing it?

I am trying to fix a bug in a cspell package which fails to install from git clone and I am facing a conundrum.
I found that the installation expects to copy files from dist/ folder which does not exist in a clean clone because is produced by running npm compile
So I decided to add this into package.json scripts section:
"preinstall": "npm run compile"
Mainly before running install, it should run compile, which I know to be producing the desired files.
Now I faced a new problem: compile fails because of missing "tsc" command. I looked and apparently this is provided by typescript package which was listed as a devDependency. Because it was missing i suspected that it was not installed because install was supposed to install only runtime dependencies and I decided to try to move it there. Bad luck, doing this was not enough, which means that preinstall is run before installing any dependencies.
What is the magic needed for fixing installation from source, without adding extra manual steps between clone and install command?
You should install global for typescript.
Or create script postinstall run before start main script but after install all package.

Typescript Compilation Issue

Typescript current version is 1.6.2, but when I am installing typescript and checking the version through "tsc -v" it gives me typescript version 1.0.3.0, due to which I am not being able to compile typescript.
Kindly tell me what should I do now. Need some serious help regarding this.
This installs the latest typescript globally:
npm install -g typescript

Resources