Cargo Build Error - File Missing - rust

Trying to compile the example given at https://github.com/gifnksm/twitter-api-rs on a 32bit Windows 10 machine, I get the following error - any ideas as to what to do?
(I had a previous issue with the curl-sys compilation, which required the environment variable CFLAGS setting to '-mmmx -msse' )
D:\Proj\Rust\projects\twittest>cargo build --verbose
Fresh rustc-serialize v0.3.16
Fresh pkg-config v0.3.5
Fresh libc v0.1.10
Fresh winapi v0.2.2
Fresh winapi-build v0.1.1
Fresh matches v0.1.2
Fresh log v0.3.2
Fresh url v0.2.37
Fresh advapi32-sys v0.1.2
Fresh kernel32-sys v0.1.4
Fresh rand v0.3.11
Fresh gcc v0.3.13
Fresh time v0.1.32
Compiling curl-sys v0.1.25
Running `D:\Proj\Rust\projects\twittest\target\debug\build\curl-sys-865cd014190c57f1\build-script-build`
Fresh libz-sys v0.1.8
Fresh rust-crypto v0.2.31
failed to run custom build command for `curl-sys v0.1.25`
Process didn't exit successfully: `D:\Proj\Rust\projects\twittest\target\debug\build\curl-sys-865cd014190c57f1\build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=D:\Proj\Rust\projects\twittest\target\debug\build\curl-sys-865cd014190c57f1\out/lib
cargo:rustc-link-lib=static=curl
cargo:root=D:\Proj\Rust\projects\twittest\target\debug\build\curl-sys-865cd014190c57f1\out
cargo:include=D:\Proj\Rust\projects\twittest\target\debug\build\curl-sys-865cd014190c57f1\out/include
cargo:rustc-flags=-l ws2_32
curlsys running: "sh" "-c" "/c/Users/Me/.cargo/registry/src/github.com-121aea75f9ef2ce2/curl-sys-0.1.25/curl/configure --with-winssl --enable-static=yes --enable-shared=no --enable-optimize --prefix=D:/Proj/Rust/projects/twittest/target/debug/build/curl-sys-865cd014190c57f1/out --without-librtmp --without-libidn --without-libssh2 --without-nghttp2 --disable-ldap --disable-ldaps --disable-ftp --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual"
--- stderr
thread '<main>' panicked at 'cmd.status() return the error The system cannot find the file specified.
(os error 2)', C:\Users\Me\.cargo\registry\src\github.com-121aea75f9ef2ce2\curl-sys-0.1.25\build.rs:134
I am using http://mingw-w64.org but I suspect the problem lies with the 32bit build parameters in the library configure sh files (possibly!)

My guess is that the --prefix=D:/Proj/... part is wrong, and should be --prefix=/d/Proj/....
In https://github.com/carllerche/curl-rust/blob/master/curl-sys/build.rs#L110 , there is a hardcoded replace("C:\\", "/c/") but no handling of other unit labels.
In other words, it seems curl-rust currently does not support building when your project root is not on C:. Would it be possible to move your projects directory, or at least the code for this project?

Related

Rust flo_draw graphics library is not building

The issue I'm having are regarding a copy-pasted flo_draw example program. I am using vscode and the rust-anylizer extension. It tells me failed to run build scripts, check server logs for more information apon copying the code in. I don't know how to check these or what they are. Using cargo run from the terminal yields no better results.
I tried to copy in the code below:
// src.main.rs
use flo_draw::*;
use flo_draw::canvas::*;
fn main() {
with_2d_graphics(|| {
let canvas = create_canvas_window("Hello, world");
});
}
$ cargo run
Compiling futures v0.3.25
Compiling semver v0.11.0
Compiling flo_render_gl_offscreen v0.3.0
Compiling allsorts v0.5.1
Compiling winit v0.24.0
error: failed to run custom build command for `flo_render_gl_offscreen v0.3.0`
Caused by:
process didn't exit successfully: `/<path to program>/target/debug/build/flo_render_gl_offscreen-9d539a79f1cb257c/build-script-build` (exit status: 101)
\--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn't find any valid shared libraries matching: \['libclang.so', 'libclang-*.so', 'libclang.so.*', 'libclang-*.so.*'\], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: \[\])"', /<path to home>/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.54.0/src/lib.rs:1959:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
flo_draw, or, more specifically, one of its dependencies, links to the external C library and therefore have to generate the matching API. This is done using bindgen, which requires clang to be installed in your system.
Installation instructions from the linked page:
Debian-based Linuxes
# apt install llvm-dev libclang-dev clang
Ubuntu 18.04 provides the necessary packages directly.
Arch
# pacman -S clang
Fedora
# dnf install clang-devel

Cargo: "No such file or directory" error when compiling a Rust project

I'm trying to build a Rust project with cargo (on Ubuntu 20.04), and it seems I'm running into an error when compiling some of the dependencies.
I run cargo build --release, all of the external crates are downloaded, then it begins compiling some of them, but eventually runs into the error below:
> cargo build --release
Updating crates.io index
Downloaded ansi_term v0.12.1
Downloaded phf_generator v0.7.24
Downloaded cmake v0.1.48
...
Downloaded 95 crates (6.9 MB) in 2.51s (largest was `wabt-sys` at 2.6 MB)
Compiling libc v0.2.112
...
Compiling unicode-width v0.1.9
error: couldn't create a temp dir: No such file or directory (os error 2) at path "/home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-1.0.0/home/user/rustcH0KskO"
...
And I get the exact same error for 15 other packages. It's obvious why the path wouldn't exist, but I'm not sure where to begin fixing this issue.
I've tried uninstalling and reinstalling Rust, but I'm new to the language and not sure what to do beyond that, so help is much appreciated. Thanks!
I linked it above, but the project in question is https://github.com/iden3/circom.

stack 2.7.1: build fails with resource busy (Text file busy) on Ubuntu

I'm unable to do stack build for any projects on Ubuntu 20.04 or 18.04 running as a VirtualBox guest on Windows 10. Building fails when trying to rename a temp file: .stack-cabal-mod11115-0.tmp: rename: resource busy (Text file busy)
edit: this appears to only happen on VirtualBox shared folders. Stack can successfully build a project in a folder that is not shared with the Windows hot.
I've previously had no issues with 1.9.x versions of stack in identical environments. At this point I'm not even able to get stack build to compile a new project on a clean Ubuntu installation. If I downgrade to 1.9.3 everything magically works. I've deleted ~.stack and .stack-work folders and retried without success.
Below is the output on a new project using stack new. I'm able to use stack repl, although I still get an error message about the build failing with
vagrant#ubuntu-focal:/vagrant/test$ stack --version
Version 2.7.1, Git revision 8afe0c2932716b0441cf4440d6942c59568b6b19 x86_64 hpack-0.34.4
vagrant#ubuntu-focal:/vagrant/test$ stack setup
Preparing to install GHC (tinfo6) to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-tinfo6-8.10.4.
Installed GHC.
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
vagrant#ubuntu-focal:/vagrant/test$ stack build
[1 of 2] Compiling Main ( /home/vagrant/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /home/vagrant/.stack/setup-exe-src/setup-mPHDZzAJ.o )
[2 of 2] Compiling StackSetupShim ( /home/vagrant/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /home/vagrant/.stack/setup-exe-src/setup-shim-mPHDZzAJ.o )
Linking /home/vagrant/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.4 ...
Building all executables for `test' once. After a successful build of all of them, only specified executables will be rebuilt.
test> configure (lib + exe)
Configuring test-0.1.0.0...
/vagrant/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/.stack-cabal-mod11009-2.tmp: rename: resource busy (Text file busy)
vagrant#ubuntu-focal:/vagrant/test$ stack build
Building all executables for `test' once. After a successful build of all of them, only specified executables will be rebuilt.
test> configure (lib + exe)
Configuring test-0.1.0.0...
/vagrant/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/.stack-cabal-mod11115-0.tmp: rename: resource busy (Text file busy)
Thanks.

Unable to build bevy on windows rust

I am trying to use bevy game engine with rust on windows. I have x86_64-mingw installed on my machine.
I have setup the rust tool chain default to x86_64-pc-windows-gnu. I put bevy = "0.4.0" under my dependencies in the Cargo.toml.
I tried cargo build and I get the following error
error: failed to run custom build command for `syn v1.0.63`
Caused by:
could not execute process `C:\Users\USERNAME\Projects\rust-game\target\debug\build\syn-a158346a8e8b6be7\build-script-build` (never executed)
Caused by:
Access is denied. (os error 5)
warning: build failed, waiting for other jobs to finish...
error: build failed
When I tried to compile in administrator mode syn compiled but another lib was giving error
Compiling proc-macro2 v1.0.24
Compiling syn v1.0.63
Compiling serde_derive v1.0.124
Compiling serde v1.0.124
error: failed to run custom build command for `proc-macro2 v1.0.24`
Caused by:
could not execute process `C:\Users\USERNAME\Projects\rust-game\target\debug\build\proc-macro2-a1d2a8cf734884f9\build-script-build` (never exe
cuted)
Caused by:
Access is denied. (os error 5)
warning: build failed, waiting for other jobs to finish...
error: build failed
Edit:
My Antivirus was preventing it, and denying it access, so just turning my AV for sometime worked!
I've tried compiling a project that uses bevy = "0.4.0" and was able to build with the stable-x86_64-pc-windows-msvc toolchain but not with stable-x86_64-pc-windows-gnu.
In my case, bevy-glsl-to-spirv is the crate that failed to build. On the bevy book is specified that you must have VS build tools 2019 installed. They do not explicitly say that you must use the msvc toolchain but as they require you to install VS build tools 2019 I guess you must compile the code using stable-x86_64-pc-windows-msvc.
You can download VS build tools 2019 here.
Also make sure that you install the stable-x86_64-pc-windows-msvc toolchain:
rustup toolchain install stable-x86_64-pc-windows-msvc
Set this toolchain as the default toolchain.
rustup default stable-x86_64-pc-windows-msvc
Finally, make sure the toolchain has been installed and set as the default toolchain:
rustup toolchain list
You should see:
stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc (default)
Try to cargo build and it should work like a charm.

llvm-sys - Didn't find usable system-wide LLVM

I'm trying to learn LLVM to make a programming language using Rust. I am using the llvm-sys crate that wraps around the LLVM API.
I have installed LLVM : LLVM-8.0.0-win64
My dependencies in cargo.toml
[dependencies]
llvm-sys = "80.1.1"
When I run cargo run I get the following error,
Updating crates.io index
Compiling memchr v2.2.1
Compiling lazy_static v1.4.0
Compiling regex-syntax v0.6.12
Compiling semver-parser v0.7.0
Compiling libc v0.2.65
Compiling cc v1.0.47
Compiling thread_local v0.3.6
Compiling semver v0.9.0
Compiling aho-corasick v0.7.6
Compiling regex v1.3.1
Compiling llvm-sys v80.1.1
error: failed to run custom build command for `llvm-sys v80.1.1`
Caused by:
process didn't exit successfully: `C:\Users\Name\Desktop\Carbon\carbon-lang\target\debug\build\llvm-sys-ed5d351b1ae6a41b\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=LLVM_SYS_80_PREFIX
cargo:rerun-if-env-changed=LLVM_SYS_80_IGNORE_BLACKLIST
cargo:rerun-if-env-changed=LLVM_SYS_80_STRICT_VERSIONING
cargo:rerun-if-env-changed=LLVM_SYS_80_NO_CLEAN_CFLAGS
cargo:rerun-if-env-changed=LLVM_SYS_80_USE_DEBUG_MSVCRT
cargo:rerun-if-env-changed=LLVM_SYS_80_FFI_WORKAROUND
Didn't find usable system-wide LLVM.
--- stderr
thread 'main' panicked at 'Failed to execute "C:\\Program Files\\LLVM\\bin\\llvm-config": Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', src\libcore\result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
But I have set the LLVM_SYS_80_PREFIX as C:\Program Files\LLVM which is where the bin folder is.
Should the llvm-config file be separately installed? I could not find it anywhere.
FYI: I'm on Windows 10
Thanks for the help!
llvm-config is a developer-side tool, it is not shipped with binaries. You need to build LLVM from sources.
LLVM is not shipped with a component called llvm-config.exe, I am not sure how to bypass though.

Resources