How to install ruby 2.4.0 in Windows 10 - ruby

I have ROR projects that need different versions of ruby and one of them need ruby 2.4.0. with Postgresql. I’m using a PC with Windows 10.
How can I install more than one ruby version like in Linux with rvm? and where can I download the Ruby 2.4.0 for Windows? (I saw that rubyinstaller.org doesn’t have this version)

Windows 10 comes with a new feature called Windows Subsystem for Linux (WSL) that allows you to use Bash with the most common Linux tools included the ones you need to install a Ruby Manager Version.
For this tutorial we'll set up Ubuntu on Windows, Ruby 2.4.0, Rails 5.0.1 and PostgreSQL.
Installing Bash On Windows
First enable developer mode on your machine
https://www.youtube.com/watch?v=S6NvjvL3xaI
Next install Windows Subsystem for Linux
https://www.youtube.com/watch?v=g_5hxfFKDL8
And restart your computer.
After the computer reboot open a Command Prompt (CMD) and type
> bash
You will see the next message
This will install Ubuntu on Windows, distributed by Canonical
and licensed under its terms available here:
https://aka.ms/uowterms
Press "y" to continue: y
Press "Y" to continue
Downloading from the Windows Store... 100%
Extracting filesystem, this will take a few minutes….
Bash will ask you for a user, please remember this user because bash will ask you every time you need root permissions in Bash. Also when you time your password you won’t see the keystrokes, it’s normal, only keep typing and press ENTER when you finish.
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms.wslusers
Enter new UNIX username:
Enter new UNIX password:
And your Bash is ready when you see the CMD its in the
mnt/c/Users/your_username directory.
your_username#yourmachine:/mnt/c/Users/your_username$
Installing RVM and Ruby
In your bash copy this line:
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Then install gnup2
$ sudo apt-get install gnupg2
Remember your UNIX password because every time you saw a sudo in the command you will be asked for your password.
Install RVM
$ \curl -sSL https://get.rvm.io -o rvm.sh
$ cat rvm.sh | bash -s stable
$ source ~/.rvm/scripts/rvm
Install Ruby
$ rvm install ruby-2.4.0
If you need to install other version of ruby run this same command like this
$ rvm install ruby-2.3.5
And select the ruby version you want to use
$ rvm --default use 2.3.5
To check if it works
$ ruby -v
Installing RubyOnRails
Install the Ruby’s package manager Bundler
$ gem install bundler
Add NodeJS
$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
$ sudo apt-get install -y nodejs
Install Rails
$ gem install rails
Installing PostgreSQL
Download PostgreSQL installer and follow the instructions of the installation
https://www.openscg.com/bigsql/postgresql/installers.jsp/
The installer will ask you for a user and a password, also keep them in a safe place because you will use it to access to PostgreSQL command line and in database.ymlin your ROR project.
When the installation finish, return to bash and type the next command
$psql -p 5432 -h localhost -U your_postgresql_username
Bash will ask you the PostgreSQL password and if everything works you will have access to the Postgres shell prompt
psql (9.5.6, server 9.6.2)
WARNING: psql major version 9.5, server major version 9.6.
Some psql features might not work.
Type "help" for help.
postgres=#
Type \q to exit the Postgres shell.
Running your Rails app
Open the project in your favorite editor and update the database.yml with the PostgreSQL username and password.
development:
database: your_app_name_development
username: your_postgres_user
password: your_postgres_password
host: localhost
port: 5432
test:
database: your_app_name_test
username: your_postgres_user
password: your_postgres_password
host: localhost
port: 5432
In Bash go to the directory where is your rails project, for example:
$ cd Projects/my_app
To learn more about Bash navigation visit
https://www.pluralsight.com/guides/beginner-linux-navigation-manual
Create your database
$ rake db:create
Run the rails server to make sure everything is working
$ rails s
And go to your browser and visit
$ localhost:3000
Every time you need a Bash, open a Command Prompt and type
>bash -l
For more detail of each of the commands in this tutorial, visit
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-and-set-up-a-local-programming-environment-on-windows-10
https://medium.com/#colinrubbert/installing-ruby-on-rails-in-windows-10-w-bash-postgresql-e48e55954fbf

Related

How to install rails version 4.0.4 and ruby version 2.1.1 on windows

my question is straight, Please give me answers with some details of the tools that I use. I have done some research and I am not getting a straight solution.
I am trying to run a rails application that is using rails version 4.0.4 and ruby version 2.1.1. How can I set up the environment in my windows laptop?
Maybe you should create an Ubuntu Virtual Machine using Vagrant to run your rails app.
First of all, download VirtualBox and Vagrant.
Then change to a directory where you’ll build your project C:\projects\starting_rails for example and from that directory run:
$ vagrant init hashicorp/precise32
$ vagrant up
$ vagrant ssh
Those commands will create an Ubuntu virtual machine, set it up and then you will be able to login through ssh.
Inside the vm, you'll need to config everthing in order to run you rails app.
Install the PostgreSQL
# set that default locale before install postgres
$ sudo /usr/sbin/update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
$ sudo apt-get install postgresql libpq-dev
Once installed, create the database instance. Within the SSH session
$ sudo mkdir -p /usr/local/pgsql/data
$ sudo chown postgres:postgres /usr/local/pgsql/data
$ sudo su postgres
$ /usr/lib/postgresql/9.1/bin/initdb -D /usr/local/pgsql/data
$ createuser vagrant
Respond "Y" to Shall the new role be a superuser? Then you can 'exit' the su subshell.
Add privilege for vagrant to create db.
$ psql postgres psql
$ ALTER ROLE vagrant CREATEDB;
# exit with \q
$ \q
Then it is time to install RVM a ruby version manager.
$ sudo apt-get install curl
$ \curl -sSL https://get.rvm.io | bash
# installs all the various compilers and packages you’ll need to build Ruby and common libraries
$ rvm requirements
# installs ruby
$ rvm install 2.1.1
# creates a gemset rails
$ rvm gemset create rails404
$ rvm 2.1.1#rails404
# installs the rails
$ gem install rails -v 4.0.4
# sets 2.1.1 as default ruby version
$ rvm use 2.1.1 --default
After that, install bundler.
$ gem install bundler
And last but not least install nodejs.
$ sudo apt-get install nodejs
Vagrant shares the content of your desktop folder with your vm, so you can use your desktop favorite editor, your desktop git tool and test it on your desktop browser (but you need to configure port forwarding first).
You can find more details in this tutorial.
I hope it helps.

Erros in installing PostgreSQL using homebrew

I'm using Mac OS X 10.8.5 and trying to install postgreSQL using homebrew. I've fixed several errors and warnings which have occurred when I ran brew info postgresql. However, I don't know how to fix the rest of the problems.
$brew info postgresql
postgresql: stable 9.3.2 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.3.2 (2924 files, 40M) *
Poured from bottle
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/postgresql.rb
==> Dependencies
Required: readline ✔
Recommended: ossp-uuid ✔
==> Options
--32-bit
Build 32-bit only
--enable-dtrace
Build with DTrace support
--no-perl
Build without Perl support
--no-tcl
Build without Tcl support
--without-ossp-uuid
Build without ossp-uuid support
--without-python
Build without python support
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/homebrew/issues/issue/2510
To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
http://www.postgresql.org/docs/9.3/static/upgrading.html
When installing the postgres gem, including ARCHFLAGS is recommended:
ARCHFLAGS="-arch x86_64" gem install pg
To install gems without sudo, see the Homebrew wiki.
To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres
When I run server, I get:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I've uninstalled postgresql and reinstalled but seems like I wasn't able to remove the postgresql 8.x version.
I've read several different posts to install and run postgreSQL properly and tried what they've suggested but nothing seems to be working for me.
Installing PostgreSQL in Mac OS X El Capitan using homebrew
First check the 'owner' of the folder '/usr/local' by using this command:
$ ls -la '/usr'
If the owner of the file is 'root', run this command to change the owner to your currently logged user:
$ sudo chown -R `whoami` /usr/local
Install PostgreSQL using homebrew:
$ brew update
$ brew doctor
$ brew install postgresql#15
and that's it!
Uninstall PostgreSQL using homebrew:
$ brew uninstall postgres
then remove this folder: '/usr/local/var/postgres' and then change back the owner of your local
local folder to:
$ sudo chown -R root /usr/local
How to:
List brew services: $ brew services list
Run brew services: $ brew services start <service_name>
ex: $ brew services start postgresql
Stop brew serices: $ brew services stop <service_name>
Logging in to PostgreSQL for the first time:
1.) Run the postgres: $ brew services star postgresql
2.) Create a db using your username: $ createdb `whoami`
3.) Login to postgres: $ psql
To quit psql, just type: \q
4.) Create database (using terminal):
$ createdb <db_name>
psql tutorial:
http://blog.trackets.com/2013/08/19/postgresql-basics-by-example.html
http://exponential.io/blog/2015/02/21/install-postgresql-on-mac-os-x-via-brew/
Optional, installing pgAdmin:
1.) Download pdadmin: https://www.pgadmin.org/download/macosx.php
2.) Press ctrl+click then open to run the dmg file then drag it to your
Application folder. ctrl+click the pdadmin to run it so that it won't
ask for that annoying question again.
Login in to pgAdmin:
Note: Use your username and password when you installed your postgres for first login
then create a new user with privileges later or just change your password from
'File -> Change Password...'
Your Ruby code is apparently linked against the system version of PostgreSQL, which looks for a socket in /var/pgsql_socket. The Homebrew version would look in /tmp. (At this point, make sure that a file like /tmp/.s.PGSQL.5432 exists.) To work around this, you can tell your code to connect to the Homebrew version by specifying /tmp with the "host" option, however your code spells that.
In the future, make sure your Ruby gems are linked against the Homebrew version. Perhaps just uninstalling and reinstalling with the right paths set would do it.

Installing RVM on existing ruby1.8 installation

I have a big problem with my Debian server configuration. Someone before me has made a big mess with ruby installation and now i can't manage to get it all working. What i'm trying to do now is to get back to environment, where ruby1.8 is installed and rails app is working correctly with apache+passenger. If it would be working on RVM it would be perfect. Here is the story:
There was ruby 1.8 installed on a server. The person has removed it with sudo apt-get remove ruby1.8 and then installed version 2.0.x manually using those commands:
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz
cd ruby-2.0.0-p247
./configure
make
sudo make install
Then, he has removed all the dirs listed by whereis ruby with rm command.
And here i came - i want to install RVM on this server. The problem is, no matter what i do, i get a lot of errors from all sides. Steps i've done:
# Install RVM
curl -L https://get.rvm.io | bash -s stable
# install 1.8.7 version
rvm install 1.8.7
# use 1.8.7
rvm use 1.8.7
# Install gems
bundle install
First thing (and that's just a tip of iceberg) is that i'm not able to start apache2 in cause of the following error:
apache2: Syntax error on line 203 of /etc/apache2/apache2.conf: Syntax
error on line 1 of /etc/apache2/mods-enabled/passenger.load: Cannot
load
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
into server:
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.5/libout/apache2/mod_passenger.so:
cannot open shared object file: No such file or directory Action
'configtest' failed.
Looks like there is even no /usr/lib/ruby/ dir on my system right now.
The question is: is there any way to reset all ruby-releated libraries on debian to the original state (debian without ruby installed) and install working RVM on top of that? Thanks in advance for any help.
Verify if, Is ruby installed correct by ruby -v
Install phusion passenger
$ sudo gem install passenger
$ sudo passenger-install-apache2-module
and then follow onscreen instructions

Getting Redis up an running with ruby

I have installed Redis via gems, but am having a problem getting it started.
Following James Edward Gary II steps http://blog.grayproductions.net/articles/setting_up_the_redis_server/
I have:
$ sudo gem install ezmobius-redis
Password:
Successfully installed ezmobius-redis-0.1
1 gem installed
Installing ri documentation for ezmobius-redis-0.1...
Installing RDoc documentation for ezmobius-redis-0.1...
$ redis-server path/to/redis.conf
-bash: redis-server: command not found
Any thoughts as to what I am missing?
If you have done just what you have described in your question, then you are missing redis. ezmobius-redis is just a Ruby library that allows connecting to redis. redis itself is a separate piece of software running independently.
If you followed the article you linked and if you especially did this:
curl -O http://redis.googlecode.com/files/redis-1.0.tar.gz
tar xzvf redis-1.0.tar.gz
cd redis-1.0
make
sudo cp redis-server redis-cli redis-benchmark /usr/local/bin
then you have actually installed a very old version of redis into the /usr/local directory.
If you did this starting the server did not work, then you probably have /usr/local not in your PATH. You can start the server using:
$ /usr/local/bin/redis-server path/to/redis.conf
However, I would suggest to install the newest version of redis. To do that on OSX you should use homebrew:
- Read this (https://github.com/mxcl/homebrew/wiki/Installation) as a guide on how to install homebrew and then do a
brew install redis
to install the newest version of redis.
You might need to open a new terminal to get the latest path settings. Try typing "bash" or "xterm &" and typing the redis-server command again.

Cannot set up RVM in Xubuntu on VMware

I am attempting to install RVM on Xubuntu and am having no luck getting the OS/terminal to recognize rvm as something that it can call.
I have been following the instructions here: http://beginrescueend.com/rvm/install/
I first call:
sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
This seems to be executing correctly. I then run:
sudo echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
The text is appended to the end of the file.
Next I close out the terminal completely and reopen it. I try running:
type rvm | head -1
It responds:
bash: type: rvm: not found
If I try just calling rvm it responds:
The program 'rvm' is currently not installed. You can install it by typing: sudo apt-get install ruby-rvm
Clearly I am doing something wrong, I cannot seem to determine what that is. Thank you.
By using the sudo version of the install script, you have installed the multi user version of rvm, and then you ran the single user "sourcing" script with sudo...
When using the multi user version, rvm will not install into $HOME/.rvm, but in /usr/local/rvm.
Therefore you will have to use the multi user way to source the rvm script, and that is to add your user to the rvm group.
As shine already posted though, you probably didn't want to install system wide rvm to start with.
Don't do it with sudo. You have installed it for a root and you're not a root.
RVM should be installed in your home folder, you don't need superuser privileges for that.

Resources