Error with installing "rand 0.8.3" through cargo - rust

I'm having an issue where Cargo refuses to build rand 0.8.3, I get this error message about a misplaced ":"
I'm very new to rust and cargo so this may be a very simple question and it's based off following the rust language tutorial listed on the official rust website
What have I done wrong?
I'm on Fedora 36 in case it helps
Does $LD_LIBRARY_PATH have an unterminated quote character?
Caused by:
failed to join path array: ["/home/my_name/Documents/Rust/Rust Learning/2: Programming a Guessing Game/target/debug/deps", "/home/my_name/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib", "/home/ru/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib"]
Caused by:
path segment contains separator `:`

May have something to do with the colon in the path: https://github.com/rust-lang/cargo/issues/3736

Related

Rust-analyzer failed to load workspace

rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.tml file /home/eth/Downloads/testing/Cargo.toml, cargo 1.33.0-nightly (0d1f1bbea 2018-12-19): Failed to run '"cargo" "metadata" "--format-version" "1" "--manifest-path" "/home/eth/Downloads/testing/Cargo.toml" "--filter-platform" "x86_64-unknown-linux-gnu"': 'cargo metadata' exited with an error: error: Found argument '--filter-platform' which wasn't expected, or isn't valid in this context
I needed to reinstall my OS few days back, and when I installed and configured my plugins in NeoVim - CoC is being used for code suggestion -, that error came out. I believe that's not a NeoVim/CoC problem, that's why I tagged it so. I don't have much experience dealing with that kinda stuff, so I don't even know what else information I could provide...
Update Rust.
rust-analyzer invokes the command cargo metadata with the flag --filter-platform. This flag was added in Rust 1.41.0. Since you're using an older Rust version (1.33.0), Cargo complains.

Cargo error: unable to get packages from source

error: failed to download `adler v1.0.2`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/home/actionanand/.cargo/registry/src/github.com-1ecc6299db9ec823/adler-1.0.2/Cargo.toml`
Caused by:
could not parse input as TOML
Caused by:
unexpected character found: `\u{0}` at line 1 column 1
Rust .toml file was full of red line when we add new dependency
This is caused by the crash of internal package (say cargo)
we can solve this by following the steps
Please clear the cargo registry
rm -rf /home/username/.cargo/registry/
And follow the proceedure shown after this, if you use old version
For the reference, I've given the proceedure also below:
If you are trying to migrate from the previous edition (2018), the
process requires following these steps:
1. Start with `edition = "2018"` in `Cargo.toml`
2. Run `cargo fix --edition`
3. Modify `Cargo.toml` to set `edition = "2021"`
4. Run `cargo build` or `cargo test` to verify the fixes worked
More details may be found at
https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html
You may need to to add --allow-no-vcs sometimes (it'll be prompted by the terminal) as below
cargo fix --edition --allow-no-vcs

cabal install fails with "arithmetic overflow"

I saw a possible solution for an utf8 problem here: Read file with UTF-8 in Haskell as IO String. I wanted to try that out, but I'm having a problem I can't resolve.
When I run the command cabal v2-install encoding --lib almost everything works but fails in the end with these lines:
[8 of 8] Compiling Main ( /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/setup.hs, /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/Main.o )
Linking /tmp/cabal-install.-169090/dist-newstyle/tmp/src-169090/encoding-0.8.5/dist/setup/setup ...
Configuring encoding-0.8.5...
Preprocessing library for encoding-0.8.5..
arithmetic overflow
cabal: Failed to build encoding-0.8.5. See the build log above for details.
If I add --verbose=3 to the command line the last few output lines are
creating dist/build/Data
creating dist/build/Data/Encoding
Data/Encoding/ISO88592.hs generated from mapping
Data/Encoding/ISO88592.mapping
arithmetic overflow
CallStack (from HasCallStack):
   die', called at ./Distribution/Client/ProjectOrchestration.hs:1041:55 in main:Distribution.Client.ProjectOrchestration
cabal: Failed to build
encoding-0.8.5-aa69e7dd952ebb6bcbe7b0947ad7f87838ecbfac327d0aa020c7f7f0f19b3e18.
I'm using cabal 3.2 and GHC 8.10.2 under Linux Mint 20.
I've looked "all over the place" for a solution, and the only trace of something similar is that the error is confirmed in Gentoo's Bugzilla.
Any help is appreciated!
This is apparently a bug in the library encoding (I could reproduce it), and there's a fix available as a PR on the source repository:
https://github.com/dmwit/encoding/pull/11

Package "must match -any, but the stack configuration has no specified version" on github dependency

Getting this error on my repository where I tried to use a dependency from GitHub:
$ stack build
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for quickcheck-fail-0.1.0.0:
ifctx must match -any, but the stack configuration has no specified version
needed since quickcheck-fail is a build target.
Some potential ways to resolve this:
* Set 'allow-newer: true' to ignore all version constraints and build anyway.
* You may also want to try using the 'stack solver' command.
Plan construction failed.
I'm out of ideas what exactly is wrong here. Please see the repo to reproduce: https://github.com/k-bx/quickcheck-fail
The correct answer was provided by #duplode in the comment.
It appears to be a typo: you have ifctx rather than ifcxt in package.yaml/the .cabal file. (It's an easy typo to make: I did the same thing the first few times I tried hoogling it, and even so it took me a while to notice it in the files :)) – duplode 3 hours ago

Error in attempting to create a new Stack project with GHCJS compiler

I am attempting to set up a new Stack project on NixOS with GHCJS as the compiler following the instructions at http://docs.haskellstack.org/en/stable/ghcjs.html
I have included in my stack.yaml file the following lines of code (all on one line because tab spaces seem to give issues):
# Compiler specifying the GHCJS compiler for this project (using improved base).
compiler: ghcjs-0.2.0.20151230.3_ghc-7.10.2
compiler-check: match-exact
setup-info:
ghcjs: source:
ghcjs-0.2.0.20151230.3_ghc7.10.2:
url: "https://github.com/nrolland/ghcjs/releases/download/v.0.2.0.20151230.3/ghcjs-0.2.0.20151230.3.tar.gz"
and I have retrieved the following error message when I ran stack setup
Could not parse '/home/lorkaan/pandocJS/stack.yaml':
InvalidYaml (Just (YamlParseException {yamlProblem = "mapping values are not allowed in this context", yamlContext = "", yamlProblemMark = YamlMark {yamlIndex = 487, yamlLine = 12, yamlColumn = 17}}))
See https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md.
Additionally, I tried removing the setup-info field because Stack was complaining about it, leaving my stack.yaml file like:
# Compiler specifying the GHCJS compiler for this project (using improved base).
compiler: ghcjs-0.2.0.20151230.3_ghc-7.10.2
compiler-check: match-exact
which produces this output with the stack setup command:
Warning: /home/lorkaan/pandocJS/stack.yaml: Unrecognized field in ProjectAndConfigMonoid: compiler
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.
The following executables are missing and must be installed: make
Does anybody have any idea why this would be happening?
the first error is because of a basic syntax error in your YAML configuration. The correct version would be:
setup-info:
ghcjs:
source:
ghcjs-0.2.0.20151230.3_ghc7.10.2:
url: "https://github.com/nrolland/ghcjs/releases/download/v.0.2.0.20151230.3/ghcjs-0.2.0.20151230.3.tar.gz"
The second error is because of exactly what it says: you are lacking the make utility. You need to use your Linux distribution's package management system to install make. Since I don't know which distribution you are on, I can only recommend simply executing the $ make command and seeing if the environment is smart enough to point out which package it can be found in. Ubuntu typically does that. Then it's only a matter of apt-get install-ing the package, or possibly yum install-ing on e.g. CentOS and Fedora, etc.
P.S. questions like yours normally get a downvote for not having shown sufficient effort in diagnosing the problem (or for putting 2 totally separate problems under a single question) but I'm giving you the benefit of the doubt and just hoping you'll be tidier next time.

Resources