What is appropriate way to install ruby on Ubuntu 14.04 - ruby-on-rails

I have a computer serves as a server. I have bitnami-gitlab stack on it. And now I want to install my rails app to this server. The thing confuses me, bitnami-gitlab has ruby interpreter and other apps (rails , gem, bundler etc.). Gitlab application uses git user on ubuntu. When I type;
sudo su git
which ruby
It gives me the directory of ruby which is inside of bitnami installation directory. Now, I want to install ruby, rails, apache and passenger to deploy my rails app. What is the appropriate way to do? I want to start my rails app as boot time. Should I install ruby to root user or my own user?
When I install ruby, will my gitlab application crahs?

Here is how I do it >
First, update apt-get:
sudo apt-get update
Then if you do not have it install Curl, for installing RVM
sudo apt-get install curl
Then run the appropriate RVM install there are multiple options like added rails, puma JRuby etc. check RVM website for more info. For just ruby run >
\curl -L https://get.rvm.io | bash -s stable
Now exit the shell session and start a new one
source ~/.rvm/scripts/rvm
RVM has its own requirements that can be auto installed by running >
rvm requirements
Now managing you ruby environments is easy and you can have multiple versions without making a mess.
To install any ruby version you need just run (x.x.x) version of the ruby>
rvm install x.x.x
To list versions you have installed run >
rvm list
Note also that now you can specify in your GEMFILE what version to use. Simply add ruby 'x.x.x' and rvm uses the version you specified as long as its already installed. Not having it raises error.

Related

Ruby/Rails is contradicting itself, what should I do?

I am trying to learn Ruby on Rails, I have installed Ruby, ruby -v gives ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18] and I have installed rails using gem install rails however when I run rails -v I get the following dialogue.
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
I then do as the prompt asks and run sudo gem install rails (inputting my pw) which gives me;
Successfully installed rails-6.0.2.2
Parsing documentation for rails-6.0.2.2
Done installing documentation for rails after 0 seconds
1 gem installed
to check that Rails has installed properly I run rails -v again, and again I get;
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
Am I missing something very obvious?
The best way to manage your Ruby/Rails environment is to use a tool like rvm and never use the system Ruby/Rails. Changing Ruby/Rails versions globally for all your apps will most likely break them, so you want each app to be locked to a specific Ruby/Rails version and only upgrade each one manually.
Start by installing RVM locally for your user:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
source $HOME/.rvm/scripts/rvm
Make a directory for your app.
mkdir my_rails_app && cd my_rails_app
Make a local .ruby-version and .ruby-gemset for each project:
echo 2.6.5 > .ruby-version
echo my_rails_app > .ruby-gemset
rvm reload
Then install rails only for the specific gemset "my_rails_app" (I usually give each app its own gemset).
gem install rails
rails new my_rails_app .

rvm installation on Ubuntu for managing different rails applications

I need to install rvm on a new Ubuntu machine.
I would use rvm to switch to different ruby versions and gemsets required by different Ruby on Rails applications.
rvm suggests to use the Ubuntu package.
However Internet documentation on Rails on Ubuntu, such as at RailsApp, suggests to install rvm using instead the curl command with the --ruby or --rails options and the --autolibs=enable option for avoiding missing libraries:
$ \curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enable
I could not find information specific to the --rails option, so I do not understand what it does, install only the rails gem or install rails plus other gems useful for the rails environment, like bundler and json for instance. There is a bug however: RVM does not install Rails when invoked with curl.
Considering that I do not need the rails gem in the global gemset, supposing that the above bug will soon be fixed, what is in the end the best choice for installing rvm in Ubuntu: the Ubuntu package or the curl command with the (hopefully explained) --rails option plus the --autolibs=enable option?
It depends on your Ubuntu Version.
lsb_release -a
Then you can search for the instructions based on your Ubuntu Release.
For example I am using Linux Mint based on Ubuntu Xenial 16.
Ubuntu uses the apt package manager to install packages
To find packages type in your terminal
apt search rvm
it will return a list of packages. To learn more about apt use:
apt --help
apt <command> --help
man apt
To install RVM you need to always reference their official webpage or github page
For ubuntu RVM has an official Ubuntu Page which give you the following instructions:
https://github.com/rvm/ubuntu_rvm
Follow those instructions

Trying to set up Ruby Rails on Mac

Am trying to set up rails on mac using rbenv and Homebrew.
Currently getting the following message when attempting to 'gem install rails':
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
username-mbp:projects username$ gem install rails
Any ideas??
If you are using rbenv, you should not use sudo to install gems. rbenv very helpfully installs your gems under your home directory in a way that allows you to use different gems for each installed Ruby version. When you change versions of Ruby you will really appreciate this.
To see the current version of Ruby, use rbenv local. For me this prints:
2.2.2
To see all the Ruby versions on your system of which rbenv is aware:
rbenv versions
rbenv stores the version specifier in a file called .ruby-version. This allows you to use different versions of Ruby for different projects, each version having its own set of gems.
When you try to install rails and get the Gem::FilePermissionError, it means that rbenv is not active, or you are deliberately installing into the "system" Ruby. There is nothing wrong with this per se, but you are not taking advantage of rbenv.
I recommend installing Rails again, using rbenv local to ensure that you are adding the gems to the correct path. You'll know this is working when
gem env gemdir
produces something like:
/Users/username/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
See https://github.com/sstephenson/rbenv#installation for more info.
This probably means that you used sudoat some point, which means that you run a command that allows you (as a permitted user to execute a command as the superuser or another user) See here: http://linux.about.com/od/commands/l/blcmdl8_sudo.htm.
Can you please paste the commands you used for installing rbenv, ruby, gem, brew, etc.? Also please paste the output of brew doctorto see if environment is correctly configured for Homebrew. Also, please paste the OSX version and rbenv versionsif rbenv is installed.
The steps for installing ruby on rails on OSX are:
Install Homebrew by:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`` (as seen here: http://brew.sh/). Run brew doctor and brew updateto see if everything is fine.
Install ruby: OS X comes with Ruby installed (Mavericks/Yosemite even gets version 2.0.0, previously it was only 1.8.7).
Install rbenv: it can be done either by GitHub Checkout or Brew. You probably should use brew. Run brew install rbenv ruby-build(this will also install ruby-build -https://github.com/sstephenson/ruby-build#readme-). You can also use this command brew install rbenv ruby-build rbenv-gem-rehash. Then echo 'eval "$(rbenv init -)"' >> ~/.bash_profile (to enable shims and autocompletion). You should problably run this too: echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile. Close terminal and open it again. Install the preferred version of ruby (if you want): rbenv install 2.0.0-p353.
Install Bundler: gem install bundler.
Install SQLite: gem install sqlite3
Install Rails: gem install rails.
So, the error you are having is due to permissions (you can understand about them here: http://www.tutorialspoint.com/unix/unix-file-permission.htm). Many people suggest fixing the issue with sudo or chown (http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/). I don't recommend that as it messes with system configuration. It will be better that you run:
rbenv install 2.1.2
rbenv global 2.1.2
gem update --system
When I run with this error like a year ago, what I did was uninstall everything and start again... but, probably that'll take too long.
These links might help you:
ruby for mac, ruby rbenv, rbenv githube, rubies and gems, question on stack
Use sudo:
sudo gem install rails
This guide helped me a lot: Setup Ruby On Rails on
Mac OS X 10.10 Yosemite

Facing difficulty in Installation of Interactive Ruby shell and ruby in ubuntu 13.04 and getting started with rails

Accidently I have installed both versions of ruby on my system and now the default version is set to
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
but I need to set the default version to 2.0.0...
for this I used the command
$ rvm 2.0.0p294 --default
but it says rvm is not currently installed though I installed it, typing various commands(via google) .
Also I want to install an Integrated Ruby shell in ubuntu 13.04, do suggest how to do it.
I have also installed Aptana Studio on my system, now how should I get started with it.
Finally, the last problem is tell me how to check whether rails is currently installed in my system or not...
Thanx in advance!!
to use a gemset try writing
rvm use ruby_gemset_version
to check the rails version try to type rails -v
you have to install RVM (ruby version manager), then you have control to use any specific versions of ruby, and coming to rails you have to manually install rails gem once you have installed rvm and selected a version.
This would be helpful to install rvm
https://rvm.io/rvm/install
After installation you have to install ruby versions.
Then you can use the following cmd
$ rvm use 2.0.0
to use ruby 2.0.0
Thank you.
Go to this http://rvm.io/rvm/install It has instruction to install and cofigure RVM. It is dependant on CURL lib. So make sure you have curl installed in your system, if not then the command is
#sudo apt-get install curl
Once it is intalled and configured properly.
On Ubuntu:
GoTo Terminal > Profile Preferences > Title and Command > Set checkbox for (Run command as login shell)
Install rubies using rvm install.

installing ruby on rails from development onto production server

I have been developing rails applications on windows xp. I now need to deploy these apps to a different computer, which has Ubuntu 10.04.1 LTS. To install ruby and rails on my windows machine, I used the RailsInstaller. I now need to get ruby and rails working on my Ubuntu machine. It isn't connected to the internet so pretty much every tutorial I found hasn't worked. Can I just transfer my installed files from my windows machine? In my RailsInstaller directory on my windows machine, there is the following directories: DevKit, Git, Ruby1.9.3, and scripts. It also has unins000.exe and unins000.dat. Will it work to just transfer these files or is there some other way to get ruby on rails working on my Ubuntu machine?
Windows and Ubuntu are two different operating systems. Read about operating systems here
You cannot copy software files from one Operating system to another. You can only move code and documents (images, music etc).
Anyway, since you are using Ubuntu, the tool that allows you to install software is called 'aptitude'. You will install software 'packages' from the terminal. It is similar to the command prompt in windows. You can open it by searching in the dash.
The command to install software is apt-get install package-name. You need to give it root privileges so you will have to prefix the command with sudo.
By default aptitude will fetch package from online repositories. But you can also make it install from a local file.
Another way for offline installation is to get the '.deb' package file of the software and run dpkg -i filename.deb.
Okay. So the idea is to download the software packages needed for ubuntu and use the installation tools provided to install them.
Ok For Ruby we have something called Ruby Version Manager or RVM. It allows you to have multiple versions of Ruby on your computer. I think that wont be necessary for you. But still we will go with RVM because of its ability to let you install ruby offline with ease.
Read more here: http://rvm.io/rvm/offline
As you might know, Rails is a gem of Ruby. In the above link you will find how to install Gems offline. Just download the Rails gem and install it using the local option of bundler. Ok I might have confused you with this paragraph. But you read the RVM documentation and you will understand.
If you do get an internet connection, there is an awesome tutorial (step by step) at DigitalOcean.com to guide you.
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
I know its for Ubuntu 12.04. But you wouldnt face much problem.
Good luck. And learn about operating systems.
Installation of Ruby on Rails for Production server is pretty straight forward. Below are the relevant steps.
1.INSTALL THE NEEDED LIBRARIES
sudo apt-get install zlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient18 libmysqlclient-dev libyaml-dev
2.DOWNLOAD AND INSTALL RUBY 1.9.3
sudo apt-get update
sudo apt-get install ruby1.9.3
Note you can install latest Ruby too.
3.INSTALL RAILS
sudo apt-get install ruby-dev
sudo apt-get install build-essential g++
sudo gem install railsconfigure rails application with nginx and unicorn
4.INSTALL SQLITE ADAPTER
sudo apt-get install libsqlite3-dev
If you passed all above steps without any ERROR, Now it's time to create a rails demo application OR SCP existing one and test it out.
Below is the steps to create new rails application
rails new demo
cd demo
uncomment therubyracer gem in Gemfile
sudo apt-get install build-essential g++
bundle install
rails g scaffold order name:string
rake db:create
rake db:migrate
Open config/routes file and uncomment root 'welcome/index' and replaced with 'orders/index'
$rm -rf public/index
That's all, Now run your Rails application.
Checkout http://railscasts.com/episodes/335-deploying-to-a-vps and search for "capistrano" to deploy. It's an art.
"It isn't connected to the internet so pretty much every tutorial I found hasn't worked"
You are way off the beaten path here. but if you can get your git repo to a machine that is connected to the internet, you can deploy to Heroku easy, and/or run capistrano from there.

Resources