oxfordcontrol / clarabel-r

Interior Point Conic Optimization Solver
Other
10 stars 2 forks source link

Rust error compiling from source v 0.5.1 #9

Closed dwinsemius closed 3 months ago

dwinsemius commented 1 year ago

At the end of a mostly successful effort I arrived at this on a linux/Ubuntu 18.04 box running R 4.2.1 . I knowI should update, but this doesn't look like an error thrown from R but rather from rust code.

Compiling clarabel v0.5.1 error[E0716]: temporary value dropped while borrowed --> /tmp/RtmpaNKTRH/R.INSTALL60e33e9c3c17/clarabel/src/rust/vendor/clarabel/src/solver/core/cones/psdtrianglecone.rs:109:18 109 e = &[T::zero(); 0]; ^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
creates a temporary which is freed while still in use
... 118 let β = e.iter().fold(T::zero(), s, x s + T::max(*x, T::zero())); //= sum(e[e.>0]) -------- borrow later used here
= note: consider using a `let` binding to create a longer lived value

For more information about this error, try rustc --explain E0716. error: could not compile clarabel due to previous error warning: build failed, waiting for other jobs to finish... make: *** [Makevars:18: rust/target/release/libclarabel.a] Error 101 ERROR: compilation failed for package ‘clarabel’

For me it's not a big deal. I was going to take a stab at answering a question on StackOverflow.

-- David Winsemius

goulart-paul commented 1 year ago

Fixed here: https://github.com/oxfordcontrol/Clarabel.rs/pull/58 and will appear in the next minor release.

The issue was that the rust borrow checker was updated in 1.63, and the old borrow checker was not happy with the code as written. The fix above satisfies both old and new borrow checkers. I have tested that the code works with compiler releases from 1.60 onwards.

Easiest fix for you though is probably just to update the compiler : rustup update stable

bnaras commented 1 year ago

Thanks @goulart-paul . Since this R package vendors the crates, I should update this repo as well, which I will.

dwinsemius commented 1 year ago

Thanks. I was running rustc 1.61.0, so I guess I can just resubmit after acquiring the new source. (I will also update rust.)

However, after installing rustup which didn't previously reside on my machine

$ snap install rustup --classic # despite the security warnings

and then getting
rustc 1.72.1 (d5c2e9c34 2023-09-13)

I''m still getting the error with this from an Rstudio console:

remotes::install_github("oxfordcontrol/clarabel-r")

Maybe I should reboot and try again?

goulart-paul commented 1 year ago

Just a clarification about requirements : the code in v0.6.0 should compile without error provide that the rust compiler is at least v1.63.

The version currently on the Clarabel.rs main branch (but not in any release yet) just makes it compatible back to rustc version 1.60. If you have updated rustc then there should be no need to update the source.

bnaras commented 3 months ago

Closing this as completed.