How to install rust built from source to different prefix? - rust

How do you x.py install rust built from git source to a prefix other than /usr/local?
I tried:
git/rust> python x.py install --prefix=/my/prefix
but it doesn't work:
error: Unrecognized option: 'prefix'

The --prefix option is in the configure command that generates x.py. So its like:
git/rust> configure --prefix=/my/prefix
git/rust> python x.py install

Related

Building kobuki_ros and kobuki_interfaces return rosidl_generate_interfaces error

To replicate full error
Requirements
Ubuntu 22.04 LTS
ROS2 HUMBLE
PYTHON3
Installation/Setup guide
Installing pyenv:
https://realpython.com/intro-to-pyenv/#virtual-environments-and-pyenv
If python3 version is < 3.8,skip this step
After you are done installing pyenv:
pyenv install -v 3.7.16
Each version of python installed will be located in pyenv directory
ls ~/.pyenv/versions
You can uninstall pythons by, don't do this
pyenv uninstall <version>
Check all python versions by
pyenv versions
For more information about the usage of pyenv, you can read the website from the link above. It provides a very detailed walkthrough pyenv
IF your python version is >3.8
Remember to source ros2
Make the workspace and localize python
mkdir turtlebot_ws && cd turtlebot_ws
pyenv local 3.7.16 #change local python for this folder
python -V
Output should be
Python 3.7.16
In this folder, download script to setup workspace for kobuki
#a virtual environment launcher that will fetch build tools from pypi (colcon, vcstools)
wget https://raw.githubusercontent.com/kobuki-base/kobuki_documentation/release/1.0.x/resources/venv.bash || exit 1
#custom build configuration options for eigen, sophus
wget https://raw.githubusercontent.com/kobuki-base/kobuki_documentation/release/1.0.x/resources/colcon.meta || exit 1
#list of repositories to git clone
wget https://raw.githubusercontent.com/kobuki-base/kobuki_documentation/release/1.0.x/resources/kobuki_standalone.repos || exit 1
After that create a virtual env with this local python version
pyenv virtualenv 3.7.16 .venv
### pyenv virtualenv <versionname> <projectname>
Activate the virtual env
pyenv activate .venv
Then install kobuki from source
mkdir src
#vcs handles distributed fetching of repositories listed in a .repos file
vcs import ./src < kobuki_standalone.repos || exit 1
Now go into the src folder and delete ecl_lite, and clone in stonier version
cd src
rm -rf ecl_lite
git clone https://github.com/stonier/ecl_lite.git
Also clone in two other repo and one more dependencies
git clone https://github.com/kobuki-base/kobuki_ros_interfaces.git
git clone https://github.com/kobuki-base/kobuki_ros.git
pip install catkin_pkg lark empy
Now we can go back to root workspace and build
cd ..
# build everything
colcon build --merge-install --cmake-args -DBUILD_TESTING=OFF
# disable any unused cmake variable warnings (e.g. sophus doesn't use BUILD_TESTING)
colcon build --merge-install --cmake-args -DBUILD_TESTING=OFF --no-warn-unused-cli
# build a single package
colcon build --merge-install --packages-select kobuki_core --cmake-args -DBUILD_TESTING=OFF
# build everything, verbosely
VERBOSE=1 colcon build --merge-install --event-handlers console_direct+ --cmake-args -DBUILD_TESTING=OFF
# build release with debug symbols
colcon build --merge-install --cmake-args -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo
Then update source workspace and deactivate venv
update the source workspace
vcs pull ./src
source install/setup.bash
pyenv .venv deactivate
Error
--- stderr: kobuki_ros_interfaces
CMake Error at /opt/ros/humble/share/rosidl_adapter/cmake/rosidl_adapt_interfaces.cmake:42 (get_executable_path):
Unknown CMake command "get_executable_path".
Call Stack (most recent call first):
/opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:130 (rosidl_adapt_interfaces)
CMakeLists.txt:55 (rosidl_generate_interfaces)
---
Failed <<< kobuki_ros_interfaces [0.64s, exited with code 1]
Aborted <<< ecl_eigen [0.05s]
Aborted <<< ecl_config [0.07s]
Aborted <<< ecl_mpl [0.07s]
Aborted <<< ecl_command_line [0.07s]
I tried building kobuki_ros_interfaces alone and it works. It fails when I try to build everything together.
The error you are getting is verbose enough for you to understand what is wrong i.e.:
--- stderr: kobuki_ros_interfaces
CMake Error at /opt/ros/humble/share/rosidl_adapter/cmake/rosidl_adapt_interfaces.cmake:42 (get_executable_path):
Unknown CMake command "get_executable_path".
Judging by this the CMake file which is called from within the [...]/rosidl_generate_interfaces.cmake is calling a function named get_executable_path. You didn't share with us the rosidl_adapt_interfaces.cmake so I had to google it.
Here is the link for the actual .cmake file that is causing the issues.
The lines that you should be interested in are lines 40-42:
find_package(ament_cmake_core REQUIRED) # for get_executable_path
find_package(Python3 REQUIRED COMPONENTS Interpreter)
get_executable_path(python_interpreter Python3::Interpreter CONFIGURE)
You are most likely missing the ament_cmake_core package that is required for the get_executable_path as the author of said .cmake file commented.
Try to get the missing package or make sure that the one that you use has the required function that is missing.

PyTorch installation from source into a second environment breaks

I installed pytorch from source and I first installed into an environment and it installed. Now with the same git repo cloned into a second environment it returns:
$ python setup.py install
Building wheel torch-1.13.0a0+gitf50a248
-- Building version 1.13.0a0+gitf50a248
cmake --build . --target install --config Release
No such file or directory
CMake Error: Generator: execution of make failed. Make command was: /home/me/miniconda3/envs/torch_source/bin/ninja install &&
I am using a different environment than torch_source but it tries to employ it which is now not there.

How to install google-cloud-bigquery on python-alpine based docker?

I'm trying to build a docker with python 3 and google-cloud-bigquery with the following docker file:
FROM python:3.10-alpine
RUN pip3 install google-cloud-bigquery
WORKDIR /home
COPY *.py /home/
ENTRYPOINT ["python3", "-u", "myscript.py"]
But getting errors on the pip3 install google-cloud-bigquery (too long for here)..
What's missing for installing this on python-alpine?
Looks like an incompatibility issue with the latest version of google-cloud-bigquery (>3) and numpy:
ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects
Try specifying a previous version, this works for me:
RUN pip3 install google-cloud-bigquery==2.34.4
Actually it seems like not a problem with numpy, which builds smoothly with all the dependency libs install, but rather with pyarrow, which does not support alpine+pip build. I've found a workaround by using alpine pre-built version of pyarrow. It is much easier than building pyarrow from source. This build works for me just fine:
FROM python:3.10.6-alpine3.16
RUN apk add --no-cache build-base linux-headers \
py3-apache-arrow=8.0.0-r0
# Copying pyarrow to site-package of actual python path. Alpine python path
# and python's docker hub path are different.
RUN mv /usr/lib/python3.10/site-packages/* \
/usr/local/lib/python3.10/site-packages/
RUN rm -rf /usr/lib/python3.10
RUN --mount=type=cache,target=/root/.cache/pip \
pip install google-cloud-bigquery==3.3.2
Update python version, alpine version and py3-apache-arrow version to install later versions. This is the latest one on the time of writing.
And make sure to remove build dependencies (build-base, linux-headers) for your release docker. I prefer multistage dockers for this.

Why rust is failing to build command for openssl-sys v0.9.60 even after local installation?

I'm facing the error failed to run custom build command for openssl-sys v0.9.60 while trying to build my rust program. Here are the main.rs and the Cargo.toml files.
main.rs
extern crate reqwest;
fn main() {
let mut resp = reqwest::get("http://www.governo.mg.gov.br/Institucional/Equipe").unwrap();
assert!(resp.status().is_success());
}
Cargo.toml
[package]
name = "get_sct"
version = "0.1.0"
authors = ["myname <myemail>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = "0.10.10"
I installed openssl locally (as suggested in this question), using:
git clone git://git.openssl.org/openssl.git
cd openssl
./config --openssldir=/usr/local/ssl
make
make test
sudo make install
Finally, I ran export OPENSSL_DIR="/usr/local/ssl"
I noted I already had a anaconda instalation of openssl which was in my default path. To change the default path of openssl to the github instalation I ran chmod -x MYPATH/anaconda3/bin/openssl and now which openssl returns /usr/local/bin/openssl.
I also have pkg-config installed (as suggested in this question). Running which pkg-config returns /usr/bin/pkg-config
However, when I run cargo run again the program print the same error message. Here is the entire error message:
> cargo run
Compiling openssl-sys v0.9.60
Compiling tokio v0.2.24
Compiling pin-project-internal v0.4.27
Compiling pin-project-internal v1.0.2
Compiling mime_guess v2.0.3
Compiling url v2.2.0
error: failed to run custom build command for `openssl-sys v0.9.60`
Caused by:
process didn't exit successfully: `/PACKAGEPATH/target/debug/build/openssl-sys-db18d493257de4f7/build-script-main` (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
cargo:rerun-if-env-changed=OPENSSL_DIR
OPENSSL_DIR = /usr/local/ssl
--- stderr
thread 'main' panicked at 'OpenSSL library directory does not exist: /usr/local/ssl/lib', /home/lucas/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.60/build/main.rs:66:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build faile
It looks like that rust is searching for ssl in /usr/local/ssl/lib. In fact, there is a /usr/local/ssl folder in my PC, but there is no lib there.
What am I doing wrong here? How can make my local installation of openssl work with rust correctly?
This solved the issue for me in Ubuntu:
sudo apt install libssl-dev
I have no experience with installing this myself but may be able to give some pointers.
First of all about your effort to install OpenSSL. After cloning the repository, you do not select any particular branch before configuring and making. This means that you are building the master branch, which is an evolving version of OpenSSL 3.0.0. This is not a supported version according to the crate's documentation. In order to build a supported version of OpenSSL, you will have to switch to some 1.1.1 branch or tag. Alternatively, you can download the 1.1.1 version from OpenSSL's download page.
That said, it does not seem necessary to install OpenSSL from source. Under the section Automatic, the documentation explains that the crate can deal with all kinds of typical OpenSSL installations. It may be easier for you to follow that, if possible in your case. If so, then you should unset the OPENSSL_DIR environment variable otherwise that will (continue to) override the crate's automatic mechanisms to find the OpenSSL installation.
If you still want to stick with the Manual configuration, then indeed you should use environment variables, and OPENSSL_DIR seems a convenient one. However, it does not mean the same thing as the openssldir parameter that you used in your configure command ./config --openssldir=/usr/local/ssl. To get the details, check out the meaning of that configuration parameter. In fact, the crate's meaning of OPENSSL_DIR corresponds to the --prefix setting (which you did not configure).
The problem you are running into now is that your OPENSSL_DIR variable points to your directory for OpenSSL configuration files, whereas the crate expects it to point to the top of the actual OpenSSL installation directory tree (which in your case seems to reside at /usr/local).
I used the following set of commands
sudo apt install pkg-config
sudo apt-get install libudev-dev
On fedora 36 I was getting error: failed to run custom build command for openssl-sys v0.9.77 when trying to install cargo-generate using cargo install cargo-generate
openssl-devel and pkg-config were already installed.
There was another complain below the main one:
Can't locate FindBin.pm in #INC (you may need to install the FindBin
module) (#INC contains: /usr/local/lib64/perl5/5.34
/usr/local/share/perl5/5.34 /usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at
./Configure line 15.
The solution was:
sudo dnf install perl
Surprisingly, perl was already installed but by running sudo dnf install perl "some additional perl stuff" got installed which resolved the issue!
run :
sudo apt install pkg-config
I used the following commands on Ubuntu on Windows:
sudo apt install libudev-dev
sudo apt install libssl-dev
this worked for me:
sudo apt install librust-openssl-sys-dev
I ran rust on Windows Subsystem for Linux (Ubuntu). The following commands have worked for me.
sudo apt install libssl-dev
sudo apt install pkg-config
Set variable openssl_dir to suitable PATH

FreeBSD with fusefs-s3fs

How i can install fusefs-s3fs on FreeBSD OS(example FreeNAS)? I just tried to install via command:
[root#freenas] #pkg install fusefs-s3fs
But it doesn't work and shows the following error:
pkg: file://usr/ports/pakages/meta.txz: no such file or directory
repository local has no meta file,using default settings pkg:
file:///usr/ports/packages/packagesite.txz: no such file or directory
unable to update repository local all repository upt o date pkg: No
packages available to install matching 'fusefs' have been found in
repositories
To use pkgng pkg(8) tool for installing packages in prebuilt binaries, it is better to resolve installation error with pkg, as using pkg is faster and don't require compiler installation.
First, run pkg update with -f to force fetching the repository:
pkg update -f
To install the package with its dependencies:
pkg install fusefs-s3fs
You may also use "pkg search" to make sure that the package available to be installed (fusefs-s3fs is available in my FreeBSD 11.1-R), run:
pkg search fusefs-s3fs
After installing fusefs-s3fs, load fuse module using:
kldload fuse
To automatically load fuse moudle on boot, add fuse_load="YES" to /boot/loader.conf file.
Note: if you still receive errors when updating packages list using "pkg update -f". Check that you can connect to pkg.FreeBSD.org , and that the pkgng repository config file /etc/pkg/FreeBSD.conf exists and configured.
Look like you have error with your FreeBSD repository. Try to install install using port:
cd /usr/ports/sysutils/fusefs-s3fs/ && make install clean
You need to build the port:
sudo portsnap fetch extract
cd /usr/ports/sysutils/fusefs-exfat; sudo make install clean
Or you can compile it as follows:
git clone https://github.com/s3fs-fuse/s3fs-fuse.git
cd s3fs-fuse
./autogen.sh
./configure
make
sudo make install

Resources