简体   繁体   中英

System-wide RVM to replace a home directory loaded on different architectures

I saw some questions like this already, but it seems that system-wide RVM has been deprecated, so none of the answers apply.

I have an NFS-mounted home directory which is accessible to me when I login to any number of different machines in our lab. As such, a locally-compiled Ruby will break when I try to use it on these different machines -- as they have different architectures.

I installed RVM as superuser, but I can't figure out how to direct my regular user account to use the superuser-selected Ruby. Instead it always tries to use the one in ~/bin .

What is the appropriate way to select the global Ruby?

I struggled with this same issue for quite a while. I ended up doing the following:

Install rvm with the following command line (note: the --path option is not mentioned in the usage, so I don't know how supported it is, but it worked for me), with the appropriate architecture in the path:

rvm-installer --path ~/tools/x86_64/rvm --version latest

Install for whatever architectures you want to be able to support. (note: make sure you don't have a.rvmrc file overriding the path, especially during the second install.)

Then add the following to your.bashrc/.bash_profile:

OS=$(uname -s)
if [[ $OS = Linux ]] ; then
>   ARCH=$(uname -m | sed 's/i.86/i686/')
elif [[ $OS = FreeBSD ]] ; then
>   ARCH=$(uname -m | sed 's/i.86/i686/')
elif [[ $OS = Darwin ]] ; then
>   ARCH=mac
else
>   ARCH=unknown
fi
export ARCH

There will be a line added by the installer in your.bash_profile that sets up the rvm function, change it to look like this:

[[ -s "$HOME/tools/$ARCH/rvm/scripts/rvm" ]] && . "$HOME/tools/$ARCH/rvm/scripts/rvm" 

You should also edit your.rvmrc file to have the following:

export rvm_path="$HOME/tools/$ARCH/rvm"

I haven't had time to fully test out this setup, but at least it appears to be invoking the correct version of RVM on the different platforms.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM