VPS server bundle install only runs as root - ruby-on-rails

I am building a digital ocean VPS server via ubuntu and I am having issues with my bundler. I have had this issue before on the local machine but I have no idea how to fix this issue. To be as specific as possible, I ran:
bundle install
in my application folder. It gives me the "Don't run bundle as root" message and I am not sure how to NOT run it as root here. On the local machine, I run:
sudo bundle install
to run as root and on the VPS server I am not using that sudo but it still runs as root=(
Does anyone know what I have to do to get bundler working on the VPS server? Thanks a ton for any advice!

So the answer is pretty easy, you are working as root so you need to create some user first.

Related

how to use bundle install without network access

I have a Windows 2012 server that is on an internal network. I used Railsinstaller to put the basic framework on the system. Rails new doesn't work when I reach the bundler section since I can't reach the net.
I have used "gem install rails -i repo --no-rdoc --no-ri" on a net accessible system then placed the gems on my server and ran "gem install --force --local *.gem".
Then "rails new D:\DTS_WEB --edge" and now fail at "unable to connect to github.com". Trying to start the rails server fails telling me that nothing has been checked out.
I modified my gems file with
"gem 'rails', path: '....\Ruby2.2.0\lib\ruby\gems\'" but it still tries github.
I installed git with Railsinstaller along with rails. How can I get past this last obstacle and force everything to use local resources?
Is it possible to build everything on the net accessible node and just copy it into place on the server to use? My first attempt at that failed.
On a machine that has a network connection, you can install your app's gems to a directory within the project using --path:
$ bundle install --path=vendor/bundle
Then, you can copy the project folder (along with all the gems in vendor/bundle) to your internal machine.

in redmine run on the correct Ruby interpreter or run as the www-data user

Some days ago I installed redmine, but lack of reading first install the DB and gave me problems with this. So I remove redmine and try to reinstall it, but i have a new problem:
redmine already installed correctly, the DB works and apache up service. I already try the bundle install in the project directory but does not give problems, so I think that it is "run on the correct Ruby interpreter or run as the www-data user"
Finally I reinstall the database and redmine. Now its work. the problem was something with the communication with de DB

Issue with Deploying Ruby on Rails on my Hosting Service

So I am trying to deploy a Rails app on my web hosting service. I have developed an app locally, but this is the first time I have tried to get it to work on another server. My service provider is Blue Host and I am on their most basic shared hosting plan. Just as a test, I created a fresh application on the server, and everything ran fine. However, whenever I add any gem to the Gemfile and run 'bundle install', I get this error:
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
Gem::Exception: Cannot load gem at [/usr/lib64/ruby/gems/1.9.3/cache/rake-10.4.2.gem] in /home/user/application
An error occurred while installing rake (10.4.2), and Bundler cannot continue.
Make sure that `gem install rake -v '10.4.2'` succeeds before bundling.
Whenever I run gem install rake -v '10.4.2' the gem installs fine.
I get similar errors that mention 'sudo' when i try to run other commands as well.
I am not quite sure what this error means. Do I not have the required permissions on my server?
Always use a continuous deployment/integration.
Capistrano does part of the job. It is very simple, you develop you application offline, push to a remote repository, like BitBucket or Github, and then Capistrano takes care of cloning the remote repository to your server (you can also have many), restarting services etc.
If you want to go a step forward you can use continuous integration, so when you push to remote tests will automatically be performed and if they pass your application will be deployed.
This is a basic introduction on how deployment works, you can check online, there are plenty of resources about how to deploy rails.
Go with root user
su root
root$ /etc/

Override windows gem version deploying to Openshift

I'm attempting to deploy a Rails app which I have developed on Windows, to Openshift. However, the bundle is not complete, because Gemfile.lock contains lines like:
pg (0.17.0-x86-mingw32)
which therefore don't get installed on the Linux instance at Openshift.
Knowing that Heroku works around this by detecting a Windows Gemfile.lock and removing it, I have tried adding a `.openshift/action_hooks/pre_build script doing either
rm Gemfile.lock
or
sed -i /mingw32/d Gemfile.lock
But neither helps. How can I deploy my app to Openshift and have it pick up suitable Linux versions of all gems?
Try including a full path to the file, like this: rm $OPENSHIFT_REPO_DIR/Gemfile.lock
You should be able to connect to the server via rhc ssh in order to test the solution.

Rails app on thin

I am trying to run a Rails app on thin.
I followed this tutorial http://www.funonrails.com/2010/03/nginx-and-thin-installation-and.html
After doing
sudo service thin start
Following is the error in the thin log file
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/source.rb:552:in load_spec_files': http://github.com/mislav/will_paginate.git (at rails3) is not checked out. Please runbundle install` (Bundler::GitError)
I have already run bundle install, and it has run successfully. A mongrel server on the same app runs fine.
What could be the problem.
Your problem is probably that you are running sudo service thin start. This now uses the root environment for ruby instead of your regular user. So in the root ruby environment bundler can't find the gems that you installed as your unprivileged user.
To prove that this is the case try running ./script/server thin or rails server thin to verify this.
The problem is that bundler installs the gems to your ~/.bundle. When you run bundler as root, passenger won’t be able to find the gems in /root/.bundle.
A solution is easy: bundle install .bundle will install the gems to ./.bundle, which should be your rails root directory.
The only thing I can think of is that possibly you have two different rubies on one system, and the one thin is using hasn't had bundle install run on it.

Resources