I'm trying to install ruby on Red Hat, via an ssh-connection, but it won't work.
I can't use yum install ruby, because I don't have the needed repositories.
I have three options for you:
1) You can install it from sources.
First of all you'll need to install some build tools and libraries.
On Centos/RedHat the easiest way to do it is using yum groupinstall 'Development Tools'.
If this doesn't work you'll need to run at least: yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel the bare minimum to build. Eventually is you have no internet access and just ssh you can SCP the single packages from your machine.
Once installed build tools , if you have internet access on those machines, I suggest also to install RVM to make less painful upgrade and not have to mess around with path definition for the new libraries and binaries.
To install it is quite simple curl -L get.rvm.io | bash -s stable will do the trick and after a rvm install <version> will permit you to install (for this user) any ruby version you want and create gemset without touch the system.
Be aware that installing new gems that need to be build will require to install other devel libraries if they have compiled extensions.
Have also a look to http://rvm.io/rubies/installing for more references about rvm use
Otherwise you can use #hizbul25 tutorial to install std ruby from source.
2) You can use omnibus, https://github.com/opscode/omnibus-ruby, is the package useb by Opscode, Mcollective and other tools to create a selfcontaines VirtualEnvironment for specific application.
You can select the gem and the ruby version you need and it will create a tgz with all you need to run ruby scripts.
This tgz can be uncompressed where you want (ex: /opt/omnibusruby/) and you'll need just to point the shebangs of your scripts to #!/opt/omnybusruby/embedded/ruby-2/bin/ruby or create a an alias /usr/bin/ruby -> /opt/omnybusruby/embedded/ruby-2/bin/ruby.
If you have no internet access at all from the server is probably the best way to prepare the package on your laptop/system and deploy it on the remote.
I recently installed Rails for the CodeReady Containers implementation of OpenShift in RHEL8/Cento8, using an OpenShift quickstart template. And in fact using rbenv now seems the cleanest way to install ruby:
sudo yum groupinstall "Development Tools"
sudo yum install readline-devel openssl-devel
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install -l
rbenv install 2.7.5
rbenv global 2.7.5
ruby -v
Related
First off, sorry for my bad English.
I'm trying to install Ruby 2.3.0 on my system with rbenv via Windows Subsystem for Linux aka Ubuntu on Windows 10. I followed this instruction (but not 100% exactly). but every time I try, It fails to build Ruby with this log.
check struct members..
check libraries....
Use ActiveTcl libraries (if available).
Search tclConfig.sh and tkConfig.sh..............................
Fail to find [tclConfig.sh, tkConfig.sh]
Use X11 libraries (or use TK_XINCLUDES/TK_XLIBSW information on tkConfig.sh).
Warning:: cannot find X11 library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options. If your Tcl/Tk don't require X11, please try --without-X11.
Can't find X11 libraries.
So, can't make tcltklib.so which is required by Ruby/Tk.
Failed to configure tk. It will not be installed.
Failed to configure tk/tkutil. It will not be installed.
configuring zlib
make[1]: Entering directory `/tmp/ruby-build.20160522033606.7696/ruby-2.3.1'
make -C ext/digest/sha2 -w --jobserver-fds=6,7 -j V= realclean
make[2]: Entering directory `/tmp/ruby-build.20160522033606.7696/ruby-2.3.1/ext/digest/sha2'
Makefile:39: *** missing separator. Stop.
make[2]: Leaving directory `/tmp/ruby-build.20160522033606.7696/ruby-2.3.1/ext/digest/sha2'
make[1]: *** [ext/digest/sha2/realclean] Error 2
make[1]: Leaving directory `/tmp/ruby-build.20160522033606.7696/ruby-2.3.1'
make: *** [build-ext] Error 2
and this is my installed package list
libx11-data/trusty,now 2:1.6.2-1ubuntu2 all [installed]
libx11-dev/trusty,now 2:1.6.2-1ubuntu2 amd64 [installed]
libx11-doc/trusty,now 2:1.6.2-1ubuntu2 all [installed,automatic]
libx11-xcb1/trusty,now 2:1.6.2-1ubuntu2 amd64 [installed,automatic]
libtk8.4/trusty,now 8.4.20-7 amd64 [installed,automatic]
libtcl8.4/trusty,now 8.4.20-7 amd64 [installed,automatic]
As you see, I installed X11, tcl, tk but my system can't detect them.
Have I done wrong? or it is just a bug?
Any help would be appreciated. Thank you for reading.
My installation follow this tutorial, go there for most recent update: link here.
1. Install Ruby
First some dependencies for Ruby:
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
Now for Ruby: there are 3 ways to install, each way conflict with each other, so choose one you think fit yours most or my suggestion: rbenv
Using rbenv (recommend)
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.3.1
rbenv global 2.3.1
ruby -v
Using rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.3.1
rvm use 2.3.1 --default
ruby -v
From the source
cd
wget http://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz
tar -xzvf ruby-2.3.1.tar.gz
cd ruby-2.3.1/
./configure
make
sudo make install
ruby -v
After install Ruby, install Bundler
gem install bundler
2. Install Rails
First you need NodeJS:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
Then install rails:
gem install rails -v 4.2.6
If you're using rbenv, you'll need to run the following command to make the rails executable available:
rbenv rehash
Now that you've installed Rails, you can run the rails -v command to make sure you have everything installed correctly:
rails -v
# Rails 4.2.6
3. Install DB
MySQL:
You can install MySQL server and client from the packages in the Ubuntu repository. As part of the installation process, you'll set the password for the root user. This information will go into your Rails app's database.yml file in the future.
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
PostgreSQL:
Currently, some bug prevents you from installing Postgres correctly, so I recommend you MySQL for now.
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-common
sudo apt-get install postgresql-9.5 libpq-dev
The Postgres installation doesn't setup a user for you, so you'll need to follow these steps to create a user with permission to create databases. Feel free to replace chris with your username.
sudo -u postgres createuser chris -s
# If you would like to set a password for the user, you can do the following
sudo -u postgres psql
postgres=# \password chris
Final Steps
Now make sure things go right not left
#### If you want to use SQLite (not recommended)
rails new myapp
#### If you want to use MySQL
rails new myapp -d mysql
#### If you want to use Postgres
# Note that this will expect a postgres user with the same username
# as your app, you may need to edit config/database.yml to match the
# user you created earlier
rails new myapp -d postgresql
# Move into the application directory
cd myapp
# If you setup MySQL or Postgres with a username/password, modify the
# config/database.yml file to contain the username/password that you specified
# Create the database
rake db:create
rails server
Make sure you have updated your Windows installation - run 'Windows 10 Upgrade Assistant' and install the Windows 10 Creators Update. Anything before this is riddled with bugs and my rbenv Rails install wouldn't work. If it still won't work after updating Windows to CU then you can always just use rvm instead. You may need to reinstall everything anyway, as its recommended to reinstall/upgrade Ubuntu if you are using WSL.
I try to install ruby and rails to start to learn ruby on rails.
I work on Windows. After many search and tries, I gave up and installed a fresh ubuntu 14 x64 in a VirtualBox.
I installed ruby with apt-get, but its files get spread all over the file system (/bin, /var...). So, I have to use always sudo and search all over the place when installing gems.
I would like, just like in windows, find a ruby tar.gz which I can decompress in a folder of mine, with all files at the same place, where I have the "control" over the files, and I can watch easily what it's hapenning while installing gems, rails, etc...
The problem : I cannot find any tar.gz (or similar archive) of ruby for linux which I simply can uncompress in a folder and work with it (I can manage the $path). The only one I can find is for Windows !
Thanks !
It sounds like what you want is Ruby's source code. Go to https://www.ruby-lang.org/en/downloads/ and look under "Compiling Ruby - Source Code". That's where you'll find the .tar.gz files you want. You'll need to compile and install it before you can actually use it. Installing normally copies files "all over the file system", but you can force it to install to a specific folder by passing the --prefix option to the ./configure script.
$ tar -xf ruby-2.2.1.tar.gz
$ cd ruby-2.2.1
$ ./configure --prefix=/my/ruby/dir
$ make && make install
You may need to install some dev packages in order to get it to compile, but any compilation errors should make it clear what you need.
These instructions are also described here.
Thank you Max for your response.
In case someone else tries to compile ruby on a fresh new ubuntu, this is what I had to do to build and use it with success :
Install missing dependencies :
get the latest "Stable Snapshot" from https://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz and not the "Current stable"
sudo apt-get install libffi-dev
sudo apt-get install zlibc zlib1g zlib1g-dev
sudo apt-get install openssl
sudo apt-get install libssl0.9.8 [[[ first, find the latest version with : apt-cache search libssl | grep SSL ]]]
sudo apt-get install ca-certificates
sudo apt-get install libssl-dev
sudo apt-get install libreadline-dev
Then :
Edit downloaded file tools/rbinstall.rb, goto line 714 and correct the typo :
change "rescue LoadErroe" to "rescue LoadError" (not corrected in date of 20 March 2015).
Run Max's instructions above
Don't move the ruby destination folder declared with "--prefix" (even if you try to correct the shells in ruby/bin)
Finally, for using rails :
sudo apt-get install libsqlite3-dev
sudo apt-get install nodejs ==> inorder to have a js runtime
In Ubuntu 10.04 I just installed rbenv.
The install command is not present.
rbenv 0.4.0-49-g8b04303
Usage: rbenv <command> [<args>]
Some useful rbenv commands are:
commands List all available rbenv commands
local Set or show the local application-specific Ruby version
global Set or show the global Ruby version
shell Set or show the shell-specific Ruby version
rehash Rehash rbenv shims (run this after installing executables)
version Show the current Ruby version and its origin
versions List all Ruby versions available to rbenv
which Display the full path to an executable
whence List all Ruby versions that contain the given executable
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/sstephenson/rbenv#readme
What am I missing?
The install command is not embedded into rbenv, it comes from the ruby-build plugin. You can install it using the command:
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
On Mac OS X you can install it through homebrew:
brew install ruby-build
On Debian (version >= 7) and Ubuntu (version >= 12.10) both rbenv and ruby-build can be installed using apt-get (or aptitude):
sudo apt-get update
sudo apt-get install rbenv ruby-build
On FreeBSD ruby-build is available in the Ports Collection, it can be install both as a binary package or build from the port:
# Using pkgng rbenv will be installed
pkg install ruby-build
# Building ruby-build form Ports will install rbenv only if the RBENV option is set
cd /usr/ports/devel/ruby-build
make install
I found that when using rbenv from a global directory, it's necessary to export the RBENV_ROOT variable, otherwise it won't load the plugins.
export RBENV_ROOT="/usr/local/rbenv"
if [ -d "${RBENV_ROOT}" ]; then
export PATH="${RBENV_ROOT}/bin:${PATH}"
fi
As everyone mentioned problem is missing ruby-build. For older versions of OS ruby-build may not be available as an apt package. In that case install using original instructions, which should've omitted the word Optional in this:
(Optional) Install ruby-build, which provides the rbenv install
command that simplifies the process of installing new Ruby versions.
git clone git#github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# OR use http
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Simply install ruby-build in ubuntu:
sudo apt-get install ruby-build
And add
eval "$(rbenv init -)"
To your ~/.bashrc
I had installed the ruby-build plugin before and installed ruby 1.9.3-p327 using
$ rbenv install 1.9.3-p327
A few days later I tried to install ruby 2.0.0-p247 using
$ rbenv install 2.0.0-p247
but I received the error message
rbenv: no such command 'install'
All I had to do was to run
$ exec $SHELL -l
and that fixed the problem.
Answered on 2021
If you're getting that error, it's very likely you have accidentally skipped one of the installation instructions:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
Replace .bashrc with whatever shell you're using, for example .zshrc, or just manually access your shell config file and paste this line:
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
I strong advise against re-installing/installing Ruby via brew or apt-get just to get around this issue. The whole point of using rbenv is to make your life easier in future when there is ruby version upgrade, or when you're working on different rails projects that require different version of ruby.
It looks like ruby-build is not present. Run this command :
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
Anyone finding their way here with this issue on OSX and already having installed ruby-build via homebrew (like me), you may solve this by just upgrading ruby-build:
brew update
brew upgrade ruby-build
This fixed the problem for me.
This issue also happens in Linux when doing a stand-alone installation of ruby-build, if the ruby-build executable is not found in the path. If installing under /usr/local, try for example:
PATH=/usr/local/bin:$PATH /usr/local/bin/rbenv install ...
I came to this solution, but looking for a macOS solution that uses MacPorts.
So, here the same command using MacPorts:
➜ ~ sudo port install ruby-build
Password:
---> Computing dependencies for ruby-build
---> Fetching archive for ruby-build
---> Attempting to fetch ruby-build-20210804_0.darwin_19.noarch.tbz2 from https://packages.macports.org/ruby-build
---> Attempting to fetch ruby-build-20210804_0.darwin_19.noarch.tbz2.rmd160 from https://packages.macports.org/ruby-build
---> Installing ruby-build #20210804_0
---> Activating ruby-build #20210804_0
---> Cleaning ruby-build
---> Scanning binaries for linking errors
---> No broken files found.
---> No broken ports found.
➜ ~ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /opt/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /opt/local/bin/rbenv-install (ruby-build 20210804)
Counting installed Ruby versions: none
There aren't any Ruby versions installed under `/Users/user/.rbenv/versions'.
You can install Ruby versions like so: rbenv install 3.0.2
Checking RubyGems settings: OK
Auditing installed plugins: OK
➜ ~ rbenv install 3.0.2
Downloading openssl-1.1.1k.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
Installing openssl-1.1.1k...
I'm looking for an Win32 wxRuby gem for Ruby 2.0, does someone know where to find it? I didn't have success trying to build it and it seems the project is dead.
I'm still on the battle, I successfully built wxRuby using Ruby 2.3 on linux Ubuntu (Xenial 16.04) and Mint (17 and 18), for both i386 and amd64, testing and using instructions from here and here:
# temporary add this source for a complete libwxgtk2.8
echo "deb http://archive.ubuntu.com/ubuntu precise main universe" | tee /etc/apt/sources.list.d/precise-copies.list
apt update
# install required packages
apt-get install libwxgtk2.8-dev libglib2.0-dev libpango1.0-dev libgtk2.0-dev libgtk-3-dev pangox-1.0-dev build-essential curl git
# install recommended swig version
wget "http://downloads.sourceforge.net/project/swig/swig/swig-1.3.38/swig-1.3.38.tar.gz?r=&ts=1471028964&use_mirror=ufpr" -O swig-1.3.38.tar.gz
tar zxvf swig-1.3.38.tar.gz
cd swig-1.3.38
./configure
make -j8
make install
# install ruby, using RVM
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 2.3.0
# wxRuby
git clone https://github.com/cinnammon/wxRuby-ng
cd ~/wxRuby-ng
export WXRUBY_EXCLUDED=GLCanvas
export WXRUBY_VERSION=2.0.1
# add "Config = RbConfig unless defined?(Config)" to the top of ./rakefile
# and change 'raise "This version of Ruby (#{RUBY_VERSION}) is not supported"'
# on line 38 for "SWIG_MINIMUM_VERSION = '1.3.37'"
rake
# I got some "extern" "static" declaration errors on some files,
# just changed "static" to "extern" and all went well
rake install
# remove source
rm /etc/apt/sources.list.d/precise-copies.list
apt update
I will keep trying to port it to Windows or maybe stick to Linux, but will update this post :)
Latest ruby version which supports wxruby gem is 1.9.1 (gem is named wxruby-ruby19, gem named wxruby is dedicated for ruby 1.8) and wxruby project is no longer developed. So if you need to use ruby 2.0 you are on your own now. But try to ask at http://www.ruby-forum.com/forum/wxruby where some of former wxruby developers are still active and eager to help.
Silly question. I went to http://rubyinstaller.org/downloads/ and installed Ruby 1.9.2, but when I pull up command prompt and type ruby -v it's not recognized as a command. Am I doing something wrong? I had version 1.8.6 installed, but I couldn't figure out how to upgrade my Ruby version so I uninstalled it and tried a fresh install.
You need to add Ruby to your path variable, regardless of your operating system.
Say you're using Windows, and Ruby is installed in C:\Program Files\ruby1.9.2\ You'll need to find out which folder the ruby executable is in (ruby.exe). Sometimes it'll be in the main folder, but usually for open source packages it'll be in the subfolder bin. To add ruby to your path, then, you'll need to use C:\Program Files\ruby1.9.1\bin
You can do this on the command line like so:
path = %PATH%;C:\Program Files\ruby1.9.2\bin
Note that %PATH% has a percent sign on either side, and that there's a semi-colon separating it from the new value. You'll have to type it in each time you start a new command line window, but it might be a good idea to try this the first time, because any mistakes in typing it in won't be permanent.
To change it permanently you can find it in Control Panel > System > Advanced System Settings. Switch to the Advanced tab, then click Environment Variables... Find path under System Variables, and add ;C:\Program Files\ruby1.9.2\bin to the end. Note that you still need a semi-colon to separate the new value from everything else, and that you don't need %PATH% this time (in face, the value you see is what %PATH% represents). Once you've done that, restart any command windows you had open, and you should be able to access things just fine!
These instructions will be different if you're using Linux or a Mac - try googling environment variables if you'd like to know more!
Did you add your bin Directory to the PATH?
Ok, when you install it, it will go in a directory:
ex: c:/program files/ruby1.9.x/
inside you will have a /bin directory which contains all the command for the command line.
To be able to use ruby in the command line, you must add it to your $PATH variable in the OS environment.
ex:
path=c:/program files/ruby1.9.x/bin;etc...
Install RVM with RUBY
sudo apt-get install curl
after install
install rvm also ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
if you face issue with the above line (Failed to connect to get.rvm.io port 443: Network is unreachable)
in browser go to https://get.rvm.io save the page in any location
make it executable file name rvm-installer
chmod +x rvm-installer
then do the following
bash rvm-installer stable --ruby
source /home/username/.rvm/scripts/rvm
then check rvm list
note the version of ruby listing on terminal
if you failed to install due to the dependency
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev
if the above steps not installed ruby latest version you can do it by
rvm install ruby-2.1.1
installation using rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.1
rvm use 2.1.1 --default ruby -v
**change terminal to login shell. open a new terminal **
then rvm use 2.1.1 => ( 2.1.1 version )
then its done!
pd#admin:~$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
programmers keep on coding with ruby.