I've only dealt with PHP or ASP in the past, brand new to Ruby on Rails and trying help with an existing app. I've copied a production app to another server for development and troubleshooting, which is running Apache 2.2 on Ubuntu 12.04 LTS. I installed ruby and passenger module as the root user, when I pull up the site in a browser, I get 'Web application could not be started' with the following message....
"It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:
When I try to to run as root, it warns that I should not run Bundler as root and that the Gemfile lists several gems more than once. I tried running bundle install on the production server, which was setup using a sudo user, it finishes successfully as complete with no warnings. When I try to run as my own sudo user on the development server I'm trying to copy to, it errors...
"The program 'bundle' is currently not installed. To run 'bundle' please ask your administrator to install the package 'ruby-bundler'"
I did install ruby via rvm as root, so I do not have an .rvm directory under my home directory as the sudo user. I have /usr/local/share/rvm, but can't find any bundle or gem command in the bin directory under that location. Should I have installed something as a sudo user or should I continue to run the bundle install as root?
Thanks in advance for any help.
You should never run bundle as root (or using sudo). When deploying, all the gems get installed to /vendor so there should not be any need for elevated permissions. I don’t recall off the top of my head whether rvm installs bundler by default - it doesn’t then you do need to install the bundler gem (which for a systemwide rvm install does require running as root.
rvmsudo gem install bundler
will use sudo to do this, while preserving the environment variables RVM needs
Frederick Cheung wrote:
You should never run bundle as root (or using sudo). When deploying, all
the gems get installed to <yourapp>/vendor so there should not be any
need for elevated permissions. I don't recall off the top of my head
whether rvm installs bundler by default - it doesn't then you do need to
install the bundler gem (which for a systemwide rvm install does require
running as root.
rvmsudo gem install bundler
Thanks for the help. It successfully installed the bundle under my user, but get this error when trying to run 'bundle install':
Fetching source index from https://rubygems.org/
Could not find sprockets-2.2.2.backport2 in any of the sources
But interesting to find those seem to be commented out in the Gemfile:
$ grep sprockets Gemfile
# gem 'sprockets-rails', '=2.0.0.backport1'
# gem 'sprockets', '=2.2.2.backport2'
I found some info about trying 'bundle update' and that gives an error as well:
$ bundle update
<snip warnings about gems listed more than once in Gemfile>
error: cannot open .git/FETCH_HEAD: Permission denied
My user owns the app directory I am running this in, is there some other directory git is trying to use?
Having run bundle as root may well have left some directories owned by root.
Where bundler tries to write files to depends on how its configured - (the .bundle/config file, if it exists may have some of these settings). In a production environment passing --deployment should result in everything being installed in your app’s directory (or in whatever --path setting you have previously passed).
Frederick Cheung wrote:
Having run bundle as root may well have left some directories owned by
Where bundler tries to write files to depends on how its configured -
(the .bundle/config file, if it exists may have some of these settings).
In a production environment passing --deployment should result in
everything being installed in your app's directory (or in whatever
--path setting you have previously passed).
I have not ran bundle completely, but I guess it could have altered some directories when I ran it the first time and hit Ctl+C while it was still trying to download and after seeing the warning not to run as root. I don't have a .bundle directory in the app directory or in my user home directory. I do see a .bundler directory in my home folder, but no config file, just cache. I cleaned it out and ran bundle update again to find the folder recreated and references to ruby 1.9.1, which I did install the Ubuntu package once but thought removed after reading that is was broken and all examples I find suggest using rvm to install ruby. I last used rvm to install ruby 1.9.3p392. I was trying to match the version of the production server where I copied this app from. So it seems something is messed up with versions. Also found I had the Ubuntu version of rvm when I had also downloaded via curl.
Anyway, since I seem to have screwed this install up with no experience setting up ruby and have learned a lot here and reading since my first try, I decided to start over and completely remove ruby and rvm. I used this to remove...
I installed all before as root, this time as my own user using sudo and this to setup ruby with rvm except I did line 7 as 'rvm install ruby-1.9.3-p392' and adjusted line 8 with same version:
My question now is if rubygems current is acceptable? I'm not sure what version the production server is running, should that be checked and matched as well?