rvm install on rhel6 - ruby

ok, so i'm coming from a python virtualenv environment, so please bear with me...
i am trying to install rvm on a non-internet visible machine (ie it doesn't have direct outside access). so
curl -L https://get.rvm.io | bash -s stable --ruby
would not work. no problems i thought, i'll just copy the file over from another machine and do a cat that worked, however, because rvm tries to download the source files directly from the web, it again failed....
so i found that if i put the tarballs under ~/.rvm/archives, i can install rvm as a single user (and take up ~200MB of my home space)... however, i want to install for multiuser for production purposes and use .rvm directories in my project. however, my /usr/local is read only (afs mount).... so rvm fails again.
any ideas? i don't particularly like the idea of having a rvm user and group.

I believe you can supply --path=/opt/rvm to the RVM install script to change the location of a multi-user installation.
I don't believe the RVM group can be changed as it relies on that group to operate correctly.

hmm... so i decided to look at the rvm-install script (ie https://get.rvm.io). basically, it was hardcoded to /usr/local/rvm, so i just changed that to /opt/rvm.
i then also had to add a check for the rvm tarball under the get_and_unpack function:
if [ -e ${rvm_archives_path}/${_file} ]
then
true
elif curl -L ${_url} -o ${rvm_archives_path}/${_file}
then download the file at https://github.com/wayneeseguin/rvm/tarball/master into /opt/rvm/archives/wayneeseguin-rvm-master.tgz
that installed rvm fine into /opt/rvm.
however, logging back in will result in -bash: __rvm_add_to_path: command not found. this is because the profile.d script is hard coded to /usr/local/, so doing a find and replace on /etc/profile.d/rvm.sh to /opt/ did the trick.
however, all the files are still group'd to rvm. which is fine, but another group i have to justify to my unix-admin.

Related

Command 'rvm' not found, did you mean:

I just installed rvm on my kali machine but after rebooting it, the terminal said that the command wasn't found and asked if I meant something else. I used curl -sSL https://get.rvm.io | bash -s stable --ruby to install and run the rvm install script. Everything went smooth and when the script finished, it said that all I had to do to get rvm running was execute source /usr/local/rvm/scripts/rvm, which I did. I even checked my path to make sure that everything was normal, and I think it is. Here is what it is:
/usr/local/rvm/gems/ruby-3.0.0/bin:/usr/local/rvm/gems/ruby-3.0.0#global/bin:/usr/local/rvm/rubies/ruby-3.0.0/bin:/opt/impacket/build/scripts-3.9:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet/tools:/usr/local/go/bin/:/root/go-workspace/bin
Can someone help me solve this?
You'll need to update your bashrc (or equivalent) so that the rvm stuff gets imported every time.
Just add source /usr/local/rvm/scripts/rvm to the end of that file

"You don't have [PATH ]in your PATH, gem executables will not run." while using "gem install --user-install bundler"

I was trying to install jekyll in my Mac and got the warning as following:
WARNING: You don't have /Users/Carrot/.gem/ruby/2.3.0/bin in
your PATH, gem executables will not run.
I checked through gem list and it shows it is installed; and I can find the jekyll through the path "/Users/Carrot/.gem/ruby/2.3.0/bin". I read a post which seems like my situation. I would like to know if it's a must to go through sudo? I now prefer to uninstall everything (since it also installed sass and bunch of things at the same time) and go through homebrew. How can I do the uninstallation?
Many thanks!
For those who have problems with #lamech-desai answer, (actually, when they do Desai's commands, it apparently works temporarily for them).
So you can easily do these:
open ~/.bshrc if you would like to use bash or ~/.zshrc if your are using zsh or etc...
$ sudo nano .bashrc ## bash users
$ sudo nano .zshrc ## zsh users
then copy and past these two lines of code at the end of the .*rc file:
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"
then simply press ctrl+s and ctrl+x. This will save the changes to .bashrc but you won't see them immediately - directly on your next shell login with your current user. One way to see the changes immediately is to switch user to root with su root and then switch back to your previous user with su <username> - and voila, your .bashrc will be reloaded. You can also check this with echo $PATH.
Thanks to #lamech-desai for great answer
If you are using arch linux just use the commands below in your terminal
[user~]$ export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
[user~]$ export PATH="$PATH:$GEM_HOME/bin"
[user~]$ gem list
[user~]$ gem update
You need to add the directory to your PATH environment variable
https://askubuntu.com/questions/406643/warning-you-dont-have-a-directory-in-your-path-gem-executables-will-not-run
If you are on a Mac like me, you need to add the PATH to the PATH environmental variable. You can do it with export command:
export PATH="/Users/Carrot/.gem/ruby/2.3.0/bin:$PATH"
If you wanna know more about this process, here is a blog post about this: Adding a Path to the Linux PATH Variable
Probably a bit odd to answer my own question but I did finally fix it somehow like a blind fly. I hope to write down the experience maybe who else is totally like me as a absolute beginner with everything wouldn't get struggling overnight.
Stage 1: from gem to homebrew (failed)
At the beginning, I did remove items that install in gem item-by-item, then I install brew-gem to do it. At some stage, it work for jekyll but not my theme. It kept popping out I didn't install a package that the theme needs even I installed it manually. So in the end, I remove everything related to jekyll from homebrew.
Stage 2: back to gem (very long path but finally made it)
I later found a page tell step-by-step to install jekyll. I am using OSX 10.13 (High Sierra) that cause me the permission problem. So I just granted access with this line:
sudo chown -R $(whoami) /usr/local/*
The * is a must or it won't work. I did the same to the ruby part
sudo chown -R $(whoami) /Library/Ruby/Gems/2.3.0/*
After that I install jekyll and bundler carefully following the instruction. And install the packages that the theme needs manually through gem install, which you can find at the Gemfile. I got the problem of jekyll-sitemap similar as this, I followed the method to install pygment.rb through gem install pygments.rb. And now my site is locally work.

RVM won't install system-wide on RHEL 6

I've been attempting to install rvm system-wide on a Red Hat Enterprise 6 system. In three tries, it always installed to my home directory.
I am a sudoer; sudo yum install emacs installed a /usr/bin/emacs.
Here is the command I gave:
sudo \curl -sSL https://get.rvm.io | bash -s stable --rails
Except for the --rails option, it's a straight copy from the installation instructions.
Regardless, the first line of the output is "Installing RVM to /home/fritza/.rvm/", and the next to last is "To start using RVM you need to run source /home/fritza/.rvm/scripts/rvm". There is no /usr/local/rvm, which is supposed to be a result of a system-wide installation.
I can't find any reference to this problem. Any ideas?
A possibility:
This is a system managed by a bureaucracy at the large higher-ed institution I work for. Maybe there is some kind of access control that blocks me from /usr/local. But if that were the case, surely the installer would have told me and quit, rather than switch over to a local install?
Other possibility:
RVM chooses the install location solely on the basis of whether it’s invoked through sudo. Could there be something in my installation that makes the installer believe it was launched into my environment?
Embarrassing error on my part...
I placed the sudo command at the start of the line instead of after the bar, for the invocation of bash.

Using rbenv doesn't work with sudo?

Any commands that use sudo don't seem to work with RBenv.
I'm trying to install ActiveRecord and it says I don't have write permission, so when I try this:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1 directory.
It says:
sudo: gem: command not found
How can I get around this?
The idea behind tools like rbenv and RVM is that you don't need to use sudo, because your entire Ruby environment exists inside your own workspace as a sandbox.
RVM allows multi-user configurations though it was originally designed for single users.
As far as I've ever seen or read, rbenv is single-user only. At no time should you need to use sudo to manipulate or change your Ruby environment when using rbenv. If you do, something is wrong. If you try to use sudo, you'll screw things up. You might not find out immediately but eventually something will pop up and you'll need to change the ownership of the files back to you.
On Linux and Mac OS you can do that pretty easily using:
sudo chown -R <your_user_name>:<your_group> ~/.rbenv
You have to run that as sudo because only the super-user can change ownership of files owned by root. sudo escalates your privileges to allow you to change those things.
I realise this is kind of old now, but this may help people in future:
rbenv-sudo is a plugin for rbenv that allows you to run rbenv-provided Rubies and Gems from within a sudo session.
https://github.com/dcarley/rbenv-sudo
My answer in "Installing Ruby 2.0 and Rails 4.0.0beta on AWS EC2" might be useful to you.
In short, the root user needs to have rbenv loaded in its environment for you to use the gems installed by rbenv. This can be done by adding the following
# /etc/profile.d/rbenv.sh
export RBENV_ROOT=/usr/local/rbenv
export PATH="${RBENV_ROOT}/bin:$PATH"
eval "$(rbenv init -)"
This should be sufficient for sudo to work. If you are writing a shell script, you might need to use
. /etc/profile.d/rbenv.sh
before using executables from other gems.
My answer is a little bit late but I have simple solution for this issue. Use symbolic links to be able use binstubs and other Ruby stuff.
ln -s ~/.rbenv/bin/rbenv /usr/local/bin/rbenv
ln -s ~/.rbenv/shims/* /usr/local/bin
I hope that helps to other users who is having the same issue.

Linux Install RVM without using CURL

My current environment (including a corporate proxy) is not allowing me to install RVM with CURL or WGET for something reason. Is there another way to install RVM from source without these utilities? Every web search I've done returns the 'curl' way.
Any ideas?
modifying rvm scripts is not a good idea
I was thinking about your question/my answer while trying to sleep... and I couldn't get an eye closed without writing you another answer. Hacking the rvm install script is really not what you should do. Rvm uses curl everywhere (installation, downloading rubies, updating, ...). And you have to download many more things -- for example gems. Replacing every curl-call in every script is not maintainable.
proposed solution
The good thing about rvm is, that is stores all its data in the ~/.rvm directory. Considering this, you can install rvm on a remote computer (or VM), which is as similar as possible (same OS, same OS version, same libraries) to your development computer. Install all the rubies, gemsets and gems you need. Then move the zipped ~/.rvm directory to your development computer and unpack it to ~/.rvm.
Don't forget to do
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
to source rvm while loading your bash.
If you ever have to update or install gems or ruby versions, do your business on the remote computer, and copy ~/.rvm again.
my experience with this setup
I use this setup (although it is automated with our CI server) for ¬2 years now for a production environment which is in a similar wicked corporate network. Changing gems/rubies is harder than it should be, but it works without an internet connection.
Edit: Added a paragraph about my experience with this setup
You find the rvm install script here. You can
download it
modify the parts where curl is used
execute the script, which now refers to the manually downloaded files
1. Download
Download this file to /tmp/rvm-installer .
Now download the rvm.tar.gz file to /tmp/rvm-1.19.6.tar.gz
2. modify the file
At line 148 begins function fetch_version. Replace it with the following function:
fetch_version()
{
echo '1.19.6' # the current version, as of writing this
}
At line 161 (within install_release) the get_and_unpack function is called.
replace the function call with:
get_and_unpack \
/tmp/rvm-${_version}.tar.gz \
rvm-${_version}.tar.gz
At line 212 (within get_and_unpack) replace
__rvm_curl ${_url} -o ${rvm_archives_path}/${_file} ||
with:
mv ${_url} ${rvm_archives_path}/${_file} ||
3. finally install rvm
cd /tmp
cat rvm-installer | bash -s -- --version latest --autolibs=enabled
Disclaimer: This is still a hack. It installs rvm, but I don't know about updating (here rvm uses curl again). Good luck :)

Resources