Installing Ruby 2.3 on WSL (Windows Subsystem for Linux) - ruby

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.

Related

Problems Installing Metasploit Framework on Ubuntu

I have encountered 3 problems while following this guide to installing Metasploit Framework on Ubuntu and Debian:
1) After installing proper version of ruby, there is a command given for installing Ruby libraries: sudo gem install bundler. When I typed that in and hit enter, it says "command not found". After some researching on the internet, I decided to remove sudo and try again. So I've entered gem install bundler and it worked fine. Will this cause any problems?
2) After installing Metasploit Framework, there is a command given to install the required gems and versions:
cd metasploit-framework
bundle install
But when I tried that, I got this error:
rbenv: version '2.1.6' is not installed
I really don't know what to do next (But I moved on).
3) Probably due to the previous problems, in the end when I executed msfconsole command, it said
could not find rake-10.4.2 in any of the sources.
run bundle install to install the missing gems
But the bundle install doesn't help either, because when I run that it says
Could not locate Gemfile or .bundle/directory
Any help would be appreciated.
EDIT: When I asked the person himself who had written the guide, regarding this, he told me to select the version of ruby I had just installed with either rebind or RVM before installing bundler, and then to run the bundle install. Could you please list the commands to do so? I am really new to Linux!
step 1 :
sudo apt-get update
sudo apt-get upgrade
step 2 :
Install dependent packages
sudo apt-get install build-essential libreadline-dev libssl-dev libpq5 libpq-dev libreadline5 libsqlite3-dev libpcap-dev openjdk-7-jre git-core autoconf postgresql pgadmin3 curl zlib1g-dev libxml2-dev libxslt1-dev vncviewer libyaml-dev curl zlib1g-dev
step 3 :
Install Ruby
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
source ~/.bashrc
rvm install 2.1.6
rvm use 2.1.6 --default
ruby -v
step 4 :
Install and configure postgresql
sudo apt-get install postgresql
sudo -s
su postgres
createuser msf -P -S -R -D
createdb -O msf msf
exit
Step 5 :
Install Metasploit Framework
cd /opt
sudo git clone https://github.com/rapid7/metasploit-framework.git
sudo chown -R `whoami` /opt/metasploit-framework
cd metasploit-framework
cd metasploit-framework
sudo bash -c 'for MSF in $(ls msf*); do ln -s /opt/metasploit-framework/$MSF /usr/local/bin/$MSF;done'
Still if you are facing any issue, you can download the iso or vm image from kali wesbite
I have this problem in kali after install metasploit-framework, and i can't run msfconsole. I solved the problem using the following method:
At change your directory to /usr/share/metasploit-framework:
cd /usr/share/metasploit-framework
and after that, install bundler with gem:
gem install bundler
then:
bundle install
at the end you need to update:
gem update --system
and it will work!
This command fixes it:
apt-get install ruby2.1-dev &&\
apt-get install libsqlite3-dev &&\
bundle install
What it does: install ruby development items

How to install Ruby on Red hat

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

RVM installed but not working?

I installed RVM on my Fedora 19 system a few months ago, and it was working fine. Then I had some other work and when I opened the machine again, it said:
# rvm
bash: rvm: command not found...
I tried to reinstall RVM, and this is what I get:
# rpm -i rvm-devel-1.17-8.fc19.x86_64.rpm
package rvm-devel-1.17-8.fc19.x86_64 is already installed
But I can't find it.
# ps ax | grep rvm
14363 pts/0 S+ 0:00 grep --color=auto rvm
Can anyone help me? What exactly is the problem?
P.S: The package rvm is there on the system.
# rpm -q rvm
rvm-1.17-8.fc19.x86_64
I recommend you to reinstall RVM, maybe it's crashed due to some event.
Use this command to implode it:
rvm implode
Or:
rm -rf ~/.rvm
Then install it by running:
sudo apt-get install curl
curl -L get.rvm.io | bash -s stable --auto
Then you'll need to reload the ~/.bash_profile file which you can do with this small command:
. ~/.bash_profile
Make sure to install other packages needed for Ruby to work:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
sudo apt-get install pkgconfig
Now install the latest Ruby:
rvm install 2.0.0
rvm use 2.0.0
ruby -v
Now you can install Rails:
gem install rails -v 4.0.0
the package rvm-devel-1.17-8.fc19.x86_64 is not rvm as per http://rpm.pbone.net/index.php3/stat/4/idpl/20537074/dir/fedora_19/com/rvm-devel-1.17-8.fc19.x86_64.rpm.html it is:
The rvm-devel package contains libraries and header files for
developing applications that use rvm.
Follow installation instructions http://rvm.io/rvm/install to get RVM installed, make sure to read the outputs as important hints might be printed for you.
to uninstall rvm use anyone of the following:
rvm implode
or
rm -rf ~/.rvm
Just to be sure restart the terminal before you try installing rvm again

wxWidgets (wxRuby) with Ruby 2.0

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.

How to Install Ruby-on-Rails in Amazon EC2

Now i m using Amazon EC2 for Ruby-on-Rails, After Login how can i Install Ruby-on-Rails.
Hope this will help
A Install RVM
$ sudo apt-get install git curl
2 Now we need to make sure we have some dependencies for our development environment so install the next few packages
$ sudo apt-get install build-essential automake libxml2-dev libxslt-dev autoconf openssl libreadline6 libreadline6-dev zlib1g subversion zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libc6-dev ncurses-dev libtool bison
3 Now it is time to install RVM which can be done easily with the next command.
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
4 Set Rvm Home Directory
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
5 load the edited bashrc file we run:
$ source ~/.bashrc
6 Check The installed RVM ----> Output - rvm is a function
$ type rvm | head -1
B Install Ruby 1.9.2 /1.9.3 using rvm
1 $ rvm install 1.9.3
2 Check ruby status
$ ruby -v
3 Make Installed Ruby Version as default
$ rvm use --default 1.9.3
C Install Rails
$ gem install rails
1 Check Rails Version
$ rails -v
D Install Passenger with Nginx Module
1 Create Nginx Default Install Directory and provide same once asked by installer
$ mkdir /home/<user>/.nginx
1 Install the Phusion Passenger gem
$ gem install passenger
2 Run the Phusion Passenger installer for Nginx
$ passenger-install-nginx-module
3 Command to Start Passanger
1 Passenger start -p

Resources