0

I am installing Ruby and rbenv on a CentOS 7 by following the instructions in this tutorial, with modifications. One of the recommended lines of code is cd followed by git clone commands. I assume that the cd should be cd /path_to_destination_of_cloned_code, so where on a CentOS 7 file system should I install the rbenv and ruby git cloned code?

Also, any other suggested changes to the code below would be much valued. I have not yet run the code below, and am still planning an optimal install methodology.


SUMMARY OF CODE MODIFIED FROM TUTORIAL:


// Install the rbenv and Ruby dependencies with yum as root:

sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel

// Switch to the user who will be using Ruby to run the following commands:
// 1.) Now we are ready to install rbenv into your home directory, and set the appropriate environment variables that will allow rbenv to the active version of Ruby:

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
exec $SHELL

// 2.) Determine which version of Ruby to install by visiting https://www.ruby-lang.org/en/downloads/ and then install it with these commands:

rbenv install -v 2.3.0  
rbenv global 2.3.0  

// 3.) Verify that Ruby was installed properly with this command:

ruby -v

// 4.) Disable Rubygems' generation of local documentation for each gem that you install with this command:

echo "gem: --no-document" > ~/.gemrc

// 5.) Install the bundler gem, to manage application dependencies:

gem install bundler

NOTE:


I found the following commands, which worked like a charm when run as a super user:

// the first line is supposed to be just dependencies, as follows:  
yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel  
yum install ruby ruby-devel rubygems //ruby-devel is required to add headers needed by some libraries
ruby -v  // confirm ruby is installed, and check version

Given that you can essentially just yum install ruby and let the distro manage all the behind the scenes, why would anyone both with the verbose approach from the tutorial above?

  • I don't know a thing about ruby, but my interpretation of the above steps is that it installs a local copy of whatever's in git://github.com/sstephenson/ruby-build.git into a non-root user's home directory. I'm assuming the tutorial itself assumed as much non-root activity as possible, otherwise root or the sysadmin could just install ruby via RPM – Jeff Schaller Feb 16 '16 at 1:54
  • @JeffSchaller Thank you. Your non-sudoer theory makes sense. When you were writing that, I was trying what I added to the end of the OP around the same time, which is just slightly more code. – CodeMed Feb 16 '16 at 2:01
  • Local installs rarely make sense, but as in many cases, this does not stop people from recommending them. Don't treat random web tutorials as gospel. Also, a better place to comment on the article would be in the article comments. – Faheem Mitha Feb 17 '16 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.