Cannot start rails 4 console on production server
Ok, found the issue... @stoodfarback was pretty close, but I thought the cause of the issue needed to be mentioned for others who might encounter the same thing.
Basically I am using a newer version of Capistrano (3.3.5) than I have used in the past and it (by default) adds 'bin' to the list of shared directories that it symlinks on each deploy.
set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp', 'public/system', "public/downloads", "public/assets")
So the deploy script created a new directory in shared called bin (which was empty) and the files used to launch rails server and console were missing. They were obviously still there in development, so it only affected production.
Removed 'bin' from the linked_dirs list and everything now works as expected.
now looks like:
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp', 'public/system', "public/downloads","publ ic/assets")
I have noticed on the last few versions of Capistrano that I have used, the format and defaults for linked_dirs keeps changing quite a bit, but I had never seen bin in that list. Not really sure why bin would need to be symlinked... it only has the default rails files and I can't think of why they would need to be removed from source control, but maybe the Capistrano team has a reason.
Hope this helps someone.
Rails: Can't start the rails console in production
This issue is related to the spring gem that preloads a rails application in the background, however, it's not advisable to run it in a production environment
Here's how I solved the issue:
I installed/re-installed the spring gem:
gem install spring
I then upsprung (removed the spring gem from) the bin/
executables:
bin/spring binstub --remove --all
Or
spring binstub --remove --all
You can now run the command below to get into rails console in production
rails c --environment=production
Also, to avoid this from occurring in subsequent occasions endeavour to make sure that the spring gem is only present in development
and test
groups in your Gemfile.
Moreso, when you're in production make sure you always provide the --without development test
argument to the bundle install
command
bundle install --without development test
and not the usual or common
bundle install
Can't start rails console in production
Instead of rails console RAILS_ENV=production
:
Use rails console production
or shorter rails c production
.
The value following the call to rails console will be taken as the environment, thus it thinks "RAILS_ENV=production" is the name of the environment it should use, instead of "production".
Rails: Production Rails console won't start
Solved it.
All I needed to do was...
$ RAILS_ENV=production bundle exec rails console
Cannot start rails console in production: invalid option -e
Like the error says, -e
is not a valid option for a rails console command (in your version of Rails). This is the proper usage:
$ rails console --help
Usage: console [environment] [options]
-s, --sandbox Rollback database modifications on exit.
--debugger Enable ruby-debugging for the console.
--irb DEPRECATED: Invoke `/your/choice/of/ruby script/rails console` instead
Rails console not working on server
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. Runrake rails:update:bin
to getbin/bundle
,bin/rails
, andbin/rake
.
Rails, Rails server suddenly does not start in development because of production database
I found out, that when I change the syntax to:
production:
database: <%= Rails.application.credentials.name-database %>
username: <%= Rails.application.credentials.username-database %>
password: <%= Rails.application.credentials.password-database %>
rails s
starts in development.
After some further research I found out that you cannot specify your credentials only in production.
rails credentials:edit --environment production
In case you scope your credentials for one environment you need to scope all environments. That is written nowhere. Again: You have to create credential files for all environments:
rails credentials:edit --environment development
rails credentials:edit --environment test
rails credentials:edit --environment production
In my case and in the applications, where I encountered problems, I used credentials only in production and relied on environment variables for development and test. For this reason I had only the production credentials for deployment. After creating credentials for all environments, even if I do not use them afterwards, the app starts in dev and production.
Related Topics
Having Trouble Installing Any Ruby 1.9.X (With Rbenv) on MAC Osx Due to Psych Yaml Parse Errors
Open_Id_Authentication - "Openidauthentication.Store Is Nil. Using In-Memory Store." Problem
Ruby SASS, Unable to Resolve Dependancies
Get SASS from Database (Compile Passed Data Instead of Reading from File)
How to Input Integer Value to an Array, Based Preceeding Row + Column Values
How to Make :Level Change Based on :Committed Days
How to Use Same Terminal Window After Using "Rails Server" Command
Cannot Click HTML Element with Watir
Understanding the Fibonacci Sequence
Bundler VS Rvm VS Gems VS Rubygems VS Gemsets VS System Ruby
How to Get Constants Defined by Ruby's Module Class via Reflection
Ruby Loading Config (Yaml) File in Same Dir as Source
How to Read a Password from the Command Line in Ruby
When to Call a "Require" in Rails