Rails app on thin - ruby-on-rails

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.

Related

You have already activated unicorn 5.2.0, but your Gemfile requires unicorn 5.3.0

I have an application running remotely, and I just upgraded rails to version 4.2.8, which upgraded other gems as well. I ran service unicorn restart afterwards, but the log for unicorn gives me this error:
You have already activated unicorn 5.2.0, but your Gemfile requires unicorn 5.3.0. Prepending bundle exec to your command may solve this. (Gem::LoadError)
I have tried gem uninstall unicorn -v 5.2.0, which returned successfully, and then gem install -v 5.3.0, which also returned successfully. Afterwards, I ran service unicorn restart, but the error persists.
I noticed the bundle exec suggestion, but I'm not sure what I should prepend this command to.
Try deleting your gemfile.lock file, and then running bundle install again, which will repopulate it from scratch, that normally sorts out my gem conflicts.
That means that the version of unicorn running on your machine is different than the version specified in your application. service unicorn is probably pointing to unicorn installed on the server/computer not pointing to your apps version of unicorn, right? Then when that starts your application, your app is trying to load a different version of the gem.
You could also run unicorn within the context of your app, like bundle exec unicorn - How to start rails server in production mode using unicorn and config file?.
If you have found a solution, good. If not, next time, create a new rails app using a unique gemset like 2.3.1#myapp.
This way, when you deploy to a remote server you will avoid this type of gems conflicts.
This could be caused by you having two different sources for gems on your machine.
If you use something like RVM with gemsets, make sure you are using the correct gemset. Especially, be sure that your gem install and gem uninstall act upon the application-sepcific gemset and not on the system-wide gems. You can find details at https://rvm.io/gemsets.
Bundler also generates a separate gemset per application. So if you use bundler, you have to run all your commands by prepending them with bundle exec (e.g. bundle exec rspec spec). If you want to remove gems from the bundle, remove it from your Gemfile and run bundle update gem_in_question afterwards (this will also update your Gemfile.lock). You can find more at http://bundler.io/v1.14/guides/using_bundler_in_application.html#executing-commands---bundle-exec.
I hope that this helps to solve your problem.

'rails c' doesn't work, but 'bundle exec rails console' does

I'm setting up the staging and production server on Ubuntu, deploy with Capistrano. Both server has pretty much the same setup. But for for some reason. I can access console on production server with rails c produciton. But when I try to access console on staging server using rails c staging
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Try: sudo apt-get install <selected package>
The only way to access console on my staging server is to do
bundle exec rails console staging
On staging
the rvm seems to be correct, I can see the ruby version I'm using.
the gemset that the application use is there.
the application is running fine. Just can't access console with 'rails c'
But for some reason, I can't access console with rails c. Any idea how to solve this issue?
I guess you didn't install rails globally. First, check your rails version you are currently using by bundle exec rails -v. Then, install rails globally by gem install rails -v <version>. This should solve your issue.
Run bundle install only makes rails available inside bundler. In most cases, this should be enough, because bundler helps prevent headaches of version conflicts.
A couple of questions to understand better the situation...
Have you tried running bundle install for the current ruby version set on rvm for that application on that server?
Have you updated the gems for another application/branch? sometimes that happens because the rails c command uses the latest gems available and bundle exec... locates and uses the gems tied to the Gemfile.lock.
The application should run fine because it uses the gems that the Gemfile.lock has listed.

Rails Server Won't Start

I'm trying to start my rails server with "rails server". I am getting the following error.
Could not find rake-0.9.2.2 in any of the sources
Run bundle install to install missing gems.
when I use gems, it say it is updated. Am I missing some type of path?
I am using MAC OSX Lion with the newest version of Ruby, Rake, Rails.
Run bundle install to make sure all the bundled gems are installed and available to the project.
Then try starting the server with bundle exec rails server - it's possible you've got the rake gem installed at the system level at a slightly different version level than what rails want. If you run rails via bundle exec, it'll set everything up for you

Unable to start Rails server

The issue is when I try to start server with rails server command after successfully created Rails app by running rails new myapp -d=mysql. However, I cant get the server to start and it gives me the following error:
Could not find gem 'mysql2 (~> 0.2.6, runtime)' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.
Then I run bundle install but could not happen.
I have installed:
Ruby 1.8.7
Rails 3.0.9 with mysql
RubyGems 1.8.7
I searched everywhere but nobody can solve my problem please help me with this issue as soon as possible. I am using Ubuntu 11.04.
Thanks in advance.
If your bundle install is saying everything is installed, try prefixing your rails command with
bundle exec rails server <other args here>
That will make sure you run the server in the context of the bundle (as defined by your Gemfile). If that fixes the problem for you, then you can either keep running the server using that command, or figure out what's wrong with your environment (might be a path issue, or you might have multiple versions of ruby or bundler installed and things aren't getting installed where you think they are)
i have reinstalled rails 4.2.4 using "gem install rails" command
and generated new project using rails new helloworld
"cd helloworld" and "rails server" would started my server.

Passenger no such file to load --bundler

I'm trying to deploy a rails app under apache (on Ubuntu 11.04) for the first time and I'm running into some issues. Basically, when I hit the site, I get an error:
no such file to load --bundler
I'm running rails 3.0 under apache and using passenger. Currently, the app lives under a subdirectory of a user directory. I've installed rvm and have pointed apache at the directory. I did a bundle install to install all the gems.
However, I think I may have screwed up by putting the site in a user directory. Should I move it somewhere under /var/www? I'm thinking that it is entirely reasonable that apache is not getting the same gemset that I have installed for the user. What do I need to do to get the user that apache is running under to have the same rvm capabilities?
I'm a bit clueless on what information you guys need to help me, so please clue me in.
Did you install the necessary gems for Rails? Install bundler by executing gem install bundler. Then go into your Rails app and type bundle install.
Also, after bundler is installed, type which bundle to see if it's in your $PATH.

Resources