Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails console not working on server

When I run bundle exec rails console production or rails console production via SSH on the server in the Current folder of the Capistrano deploy I get:

Usage:
     rails new APP_PATH [options]

Options:
    (...)

with an explanation to start a new app. Locally it works. Why can't I start a console remotely?

like image 406
Erwin Rooijakkers Avatar asked Sep 11 '25 02:09

Erwin Rooijakkers


2 Answers

I'm assuming that you updated to rails 4 from version 3 and your app can't find the executables in the bin directory. Run this to see your rails version:

$ rails -v

If your rails version is 4 or above, try running this:

$ rake rails:update:bin

Source: Rails 4 Release Notes

6.1 Notable changes

  • Your app's executables now live in the bin/ dir. Run rake rails:update:bin to get bin/bundle, bin/rails, and bin/rake.

I am using capistrano to deploy, including the capistrano/bundler gem. Since the ./bin directory is version controlled in Rails 4, we need to prevent Capistrano from linking it on deployments by removing bin from set :linked_dirs.

Now in order to prevent bundler from overwriting the version controlled binstubs, we can add the line set :bundle_binstubs, nil which will prevent capistrano-bundler from setting the --binstubs option when running bundle install.

My config/deploy.rb file now has these lines:

# Default value for linked_dirs is []
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

set :bundle_binstubs, nil

Note the lack of the bin directory in the :linked_dirs line.

like image 26
Troy Avatar answered Sep 12 '25 15:09

Troy