rvm + passenger (stand alone) GemNotFound - ruby-on-rails

I am new to Rails and trying to deploy an application to a CentOS server. I have chosen to use RVM as it seems to be highly recommended. I am open to Nginx, Apache or Passenger Stand Alone -- whatever works and is easiest.
I have struggled with this install but think that I have successfully cleaned up after myself and have now followed the instructions for single user (non-sudo) rvm install (including ssh).
One thing I don't understand is how Passenger should be installed (given that RVM is being used)?:
gem install passenger
sudo gem install passenger
rvmsudo gem install passenger
I assume that however it is installed, it should be started in the same way. I have tried each of these methods, but encounter problems in all cases.
When I started Passenger with sudo, I received:
Could not find factory_girl-3.6.1 in any of the sources (Bundler::GemNotFound)
I noticed that sometimes my ruby version would be 1.8.7 even if I set it to 1.9.3-p194 with RVM, so I uninstalled 1.8.7 (had been installed prior to RVM) and reinstalled 1.9.3-p194 (using RVM and specifying openssl again). I reinstalled passenger
Now when I do "sudo passenger start", I just get a new prompt as though nothing happened. Also if I do "sudo gem install passenger".
Finally, I notice that if I start passenger with rvmsudo that the webserver does start, however it gives an error to the console:
/usr/bin/evn: ruby: Permission denied
Any help would be greatly appreciated.

You should not use sudo:
gem install passenger
passenger start
However if you used sudo/rvmsudo - you could change permissions of some of the directories, if any of them are reported as not accessible then use this commands to fix them:
chown -R $USER: {dir}
chmod -R u+rwX,g+rwX,o+rX,o-w {dir}

Related

What is appropriate way to install ruby on Ubuntu 14.04

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.

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

Ubuntu not detecting Rails installation

I recently reinstalled Ubuntu 12.04 after the upgrade package broke my last install. I've been following this walkthrough to restore Rails and continue working on my existing projects. I've already installed rvm, all the packages listed by rvm requirements, and all my development tools (e.g., vim, git, etc.).
However, I get stuck on the rails command, whether I'm trying rails (n,s,g), and returns the error message
$ rails
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I've already done the following:
$ gem install rails
Successfully installed rails-3.2.3
1 gem installed
But based on the following checks, it still hasn't installed.
$ which gem
/home/eyoung/.rvm/bin/gem
$ which ruby
/home/eyoung/.rvm/bin/ruby
$ which rails
(no output)
I'm at my wit's end; any ideas on what's going on?
Extra details:
OS: Ubuntu 12.04 x86_64
Packages: RVM installed Ruby 1.9.3p194 w/ openssl & Rubygems
ruby and gem are on the system $PATH
EDIT: By request,
$ gem list rails
*** LOCAL GEMS ***
rails (3.2.3)
As rails gem was installed and all the other paths look correct, you need to set rvm to use that ruby as your default version. It will set all the paths correctly so you can use your gems and rails command.
rvm use 1.9.3 --default
I updated to 12.04 as well, and ran into the issue as well. After quite a bit of head scratching, I decided to reinstall rvm.
Referencing a previous question.

Can't install passenger 3 on Snow Leopard (with RVM and ruby 1.9.2)

I've been trying to install passenger with no success yet.
I've installed the gem, but when I run
passenger-install-apache2-module
it tells me
This installer must be able to write to the following directory:
/Users/myname/.rvm/gems/ruby-1.9.2-p0/gems/passenger-3.0.0
But it can't do that, because you're running the installer as myname.
Please re-run this installer as root.
but if I do
sudo passenger-install-apache2-module
I get
/Users/myname/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:762:in `report_activate_error': Could not find RubyGem passenger (>= 0) (Gem::LoadError)
from /Users/myname/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:219:in activate'
from /Users/myname/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:1065:ingem'
from /Users/myname/.rvm/gems/ruby-1.9.2-p0/bin/passenger-install-apache2-module:18:in `'
I've tried to look at those files, but cannot understand what's wrong.
can you please help?
thanks, P
Two solutions:
Use rvmsudo, not sudo.
Fix your directory permissions. /Users/myname/.rvm should be writable for myname but for some reason you caused that not to be the case.
I think you can use system ruby instead of RVM ruby for installing passenger:
rvm use default
sudo gem install passenger
sudo passenger-install-apache2-module
I actually chmod the folder as Shingara suggested and it worked.
the only thing I can't understand is why issuing the command with sudo lead to problems :(
thanks for your help!

If I install passenger via tarball and install it, how do I uninstall it?

Normally I would install phusion passenger via the gem command, but this wouldn't work for me, so I had to install it via a tarball and then run the installer.
My question is, how do I uninstall it?
dpkg -l | grep passenger
doesn't return anything. When I list the installed gems, I don't see anything either.
So i guess I have two questions
1) If installed by tarball/installer, how to uninstall
2) If I came upon this system, how could I even tell that passenger is installed? It doesn't seem to show up anywhere?
You just remove the folder it was installed to, and thats it.
You should read what the Passenger documentation has to say about removal.
The only guaranteed indicator of a passenger installation is the passenger file in the apache configuration. Usually /etc/apache2/conf.d/passenger. You must remove it, and then uninstall passenger in a method dependent on how it was installed.
If installed from a gem:
# gem uninstall passenger
If installed from a tarball:
remove the installation directory, Which is noted as the PassengerRoot directive in the aforementioned configuration file.
If installed form a deb file:
# sudo apt-get remove libapache2-mod-passenger

Resources