I'm starting to learn ruby on rails. the problem that i have is that i don't know why i get there while i want to create model
this is the command that i tried
rails generate model Book
and get this error in my ubuntu 16 terminal
/home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/app_loader.rb:40: warning: Insecure world writable dir /opt in PATH, mode 040777
/home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/application/configuration.rb:148:in `rescue in database_configuration': YAML syntax error occurred while parsing /home/android/ruby Tutorial/library/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): found a tab character that violate intendation while scanning a plain scalar at line 17 column 10 (RuntimeError)
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/application/configuration.rb:131:in `database_configuration'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-5.0.1/lib/active_record/railtie.rb:122:in `block (2 levels) in <class:Railtie>'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/lazy_load_hooks.rb:43:in `instance_eval'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/lazy_load_hooks.rb:43:in `execute_hook'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/lazy_load_hooks.rb:49:in `each'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-5.0.1/lib/active_record/base.rb:324:in `<module:ActiveRecord>'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-5.0.1/lib/active_record/base.rb:24:in `<top (required)>'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:345:in `active_record_configured?'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:263:in `disconnect_database'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:97:in `preload'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:143:in `serve'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:131:in `block in run'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:125:in `loop'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application.rb:125:in `run'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/spring-2.0.0/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/android/.rbenv/versions/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
i also tried this
rails script/generate model Book
and i get this error:
/home/android/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/app_loader.rb:40: warning: Insecure world writable dir /opt in PATH, mode 040777
rails aborted!
Don't know how to build task 'script/generate' (see --tasks)
/home/android/ruby Tutorial/library/bin/rails:9:in `require'
/home/android/ruby Tutorial/library/bin/rails:9:in `<top (required)>'
/home/android/ruby Tutorial/library/bin/spring:14:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)
//Edit
I check my database but and also check yamlint website also has error on line 17 but there is no error
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: mysql
pool: 5
timeout: 5000
development:
adapter: mysql
database: library_development
username: root
password: root1234
host: localhost
test:
adapter: mysql
database: library_test
username: root
password: root1234
host: localhost
production:
adapter: mysql
database: library_production
username: root
password: root1234
host: localhost
The main issue is of your database.yml file. You have a tab space in the file whereas the YAML files doesn't allow that since they are treated differently by different editors and tools. And the indentation is the most critical part to proper interpretation of YAML. So on line 17 fix that. And for a permanent solution keep the settings of your text editor according to that. I use Sublime in which on each page I have an option of Convert Indentation to Spaces and in its configuration I can set "translate_tabs_to_spaces": true.
Regarding the second command you were trying:
rails script/generate model Book
It belongs to Rails 2 version. Instead use the new command only:
rails generate model Book
You're using a command for Rails 2 on Rails 5.
To generate a model in Rails 5 you should use:
rails generate model Book
Check if your config/database.yml is valid using http://www.yamllint.com/
Check in your application database file.It is in /config/database.yml.If you dont have the file then you can copy from dtabase.yaml.exemple from same directory.
It is your spacing, it looks like you have 3 spaces instead of 2 in your development, test and production sections.
2 spaces:
default: &default
adapter: mysql
pool: 5
timeout: 5000
3 spaces:
development:
adapter: mysql
Related
I just deployed my app to production on heroku. However, now when I try to switch back to development and run rails c on my command prompt, I get the following error:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- sqlite3/database
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.10-x86-mingw32/lib/sqlite3.rb:9:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:76:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:72:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:72:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:61:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler/runtime.rb:61:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.7.7/lib/bundler.rb:133:in `require'
from D:/Railstutorials/Taxibol/Platform/iteration2/taxibol_operator/config/application.rb:9:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:146:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:146:in `require_application_and_environment!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Following is my database.yml file:
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
adapter: postgresql
host: ec2-23-23-210-37.compute-1.amazonaws.com
port: 5432
database: d9qgibt6qabecr
username: ygaayqvpdrfjwa
password: 'my_password'
I am facing the same issue when I want to start my server in dev mode. Where could I be going wrong?
I'd recommend installing Postgres locally so that your development and production environments are the same.
Sometimes when troubleshooting, it's helpful to run your production environment locally because there might be some other settings which you may not notice which are different in production vs. development. Running production locally is the fast way to test that, and for that you'd need Postgres installed locally because that's what you set in database.yml.
This is how to run your production server or production console locally from the terminal:
RAILS_ENV=production rails server
or
RAILS_ENV=production rails console
FYI, a great way for Mac users to install Postgres is with http://postgresapp.com/ because it's easy to get running with CMD+SPACE_BAR (system search using Spotlight) and typing in "postgres".
ran rake db:create and it worked. Though I don't know why. Would be great if someone could explain...
I have ROR version 4.0.0 and ruby version 2.0.0.After creating the project app when I try to run rails server it is showing me the error about yml file.
The screen looks like this
C:\Sites\app>rails s
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/ap
plication/configuration.rb:113:in `rescue in database_configuration': YAML synta
x error occurred while parsing C:/Sites/app/config/database.yml. Please note tha
t YAML must be consistently indented using spaces. Tabs are not allowed. Error:
(<unknown>): could not find expected ':' while scanning a simple key at line 9 c
olumn 3 (RuntimeError)
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/application/configuration.rb:103:in `database_configuration'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4
.0.0/lib/active_record/railtie.rb:174:in `block (2 levels) in <class:Railtie>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activesupport-
4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4
.0.0/lib/active_record/railtie.rb:173:in `block in <class:Railtie>'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/initializable.rb:30:in `instance_exec'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/initializable.rb:30:in `run'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/initializable.rb:55:in `block in run_initializers'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:150:in `block i
n tsort_each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:183:in `block (
2 levels) in each_strongly_connected_component'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:219:in `each_st
rongly_connected_component_from'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:182:in `block i
n each_strongly_connected_component'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_st
rongly_connected_component'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_e
ach'
from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0
/lib/rails/initializable.rb:54:in `run_initializers'
Please help me on it.
You can check your YAML file using some kind of YAML Validator
Here is your valid YAML:
development:
adapter: postgresql
database: postgres
password: 191192
pool: 5
timeout: 5000
username: postgres
production:
adapter: postgresql
database: postgres
pool: 5
timeout: 5000
test:
adapter: postgresql
database: postgres
pool: 5
timeout: 5000
My guess is that you have tabs instead of spaces in your database.yml.
Quick fix in vim:
:%s/\t/ /g
If you take a look at the trace, it tells you exactly what is wrong with your database.yml file.
"Please note that YAML must be consistently indented using spaces. Tabs are not allowed."
and
"could not find expected ':' while scanning a simple key at line 9 column 3"
So make sure that you are using spaces, not tabs, and see if you are missing a colon in line 9.
I tried to add in:
host:localhost
turns out I should have added:
host: localhost
with one space after ":"
hope this helps
I have successfully installed rails 4 and created project using rails 4.0.0
rails s
for the first time was working fine. But after adding 'devise' gem in gemfile
gem 'devise', '~> 3.0.0.rc'
and running bundle install, I am getting following error. What is the cause of this error and what will be the solution for it?
I have tried with commenting gem 'devise' section also, but now i am getting same error for every rails command.
/home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): mapping values are not allowed in this context at line 2 column 11 (Psych::SyntaxError)
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in `parse'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in `load'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/config_file.rb:318:in `load_file'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/config_file.rb:191:in `initialize'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:66:in `new'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:66:in `do_configuration'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rubygems/gem_runner.rb:46:in `run'
database.yml file
development:
adapter: mysql2
encoding: utf8
database: realstate_development
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock
gem 'devise' with any version, is showing following error on bundle, if I remove devise gem it works fine, I used rails 3.2.13 but I never faced such problem, what a strange.
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): mapping values are not allowed in this context at line 2 column 11 (Psych::SyntaxError)
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:153:in `parse'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/psych.rb:129:in `load'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb:318:in `load_file'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/config_file.rb:191:in `initialize'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems.rb:319:in `new'
from /home/siv/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems.rb:319:in `configuration'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:34:in `configuration'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:53:in `sources='
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:250:in `remote_specs'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:163:in `fetch_specs'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:67:in `specs'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:192:in `block (2 levels) in index'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `each'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `block in index'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/index.rb:9:in `build'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:185:in `index'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:179:in `resolve'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/bin/bundle:23:in `load'
from /home/siv/.rvm/gems/ruby-2.0.0-p247#global/bin/bundle:23:in `<main>'
from /home/siv/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
from /home/siv/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
If somebody still comes the same error you may to check the YAML files in your project. In this example the problem is missed indentations in database.yml. It should looks like this:
development:
adapter: mysql2
encoding: utf8
database: realstate_development
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock
I get the same error but on other grounds, and the whole problem was in incorrect application.yml
First note the yml file in which parse method fails due to Psych::SyntaxError. Then look the file for the following
The YAML files should be properly indented and correct syntax must be followed. 1.All members of a list are lines beginning at the same indentation level starting with a "- " (a dash and a space):
2.A dictionary is represented in a simple key: value form (the colon must be followed by a space):
For more syntax related information check the following link: http://docs.ansible.com/ansible/YAMLSyntax.html
I have repeatedly tried to setup my rails app on an ec2 instance using nginx and unicorn. I have found that both nginx and unicorn are set up properly; however, on both machines my rails app does not want to start up in the production environment. The output of attempting to start up in production is:
/Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:47:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:129:in `establish_connection'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:25:in `each'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/benvreed/Documents/rubydev/StudyPublic/config/environment.rb:5:in `<top (required)>'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /Users/benvreed/Documents/rubydev/StudyPublic/config.ru:4:in `block in <main>'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /Users/benvreed/Documents/rubydev/StudyPublic/config.ru:1:in `new'
from /Users/benvreed/Documents/rubydev/StudyPublic/config.ru:1:in `<main>'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/server.rb:46:in `app'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/server.rb:70:in `start'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Although, I clearly do specify the postgresql adapter in my database.yml file:
# PostgreSQL. Versions 8.2 and up are supported.
#
# Install the pg driver:
# gem install pg
# On Mac OS X with macports:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
development:
adapter: postgresql
encoding: unicode
host: localhost
database: study_development
pool: 5
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# The server defaults to notice.
#min_messages: warning
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
host: localhost
database: study_test
pool: 5
production:
adapter: postgresql
encoding: unicode
host: localhost
database: study_production
pool: 5
What's really strange is that it successfully runs in both the development and test environments. I have checked other issues on StackOverflow and most have said that it is a spacing issue; however, I have redone the database.yml file several times with the same result.
My unicorn and nginx files are standard configurations.
Any assistance would be greatly appreciated. I am at a stand still until this runs. Thanks in advance.
RAILS_ENV
When using the Rails Console by executing RAILS_ENV=production rails c, running RAILS_ENV produces:
NameError: uninitialized constant RAILS_ENV
from (irb):1
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /Users/benvreed/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Rails.env produces:
=> "production"
The adaptor in you database.yml should be pg, not postgresql.
production:
adapter: pg
encoding: unicode
host: localhost
database: study_development
My setup uses this:
production:
adapter: pg
encoding: utf8
reconnect: false
database: my_app_name_production
Your database.yml settings is ok. Nothing weird.
If the development mode runs without exceptions, thus the problem is not in the DB.
Try to check database.yml precisely: maybe invalid/unacceptable* characters present.
some symbols are so similar :) с and c
Forking error!
Maybe some caching or log problems It shows that nothing of the errors in our code.
My team resolve it.
delete the project
git clone the project
config the database.yml
start server
Everything is okay!
The same project the errors gone!
So we think it is env problems or cach or log.
see here: (https://stackoverflow.com/posts/18695551/edit)
I recently cloned a github repo and i'm trying to get it to work on my mac. I cloned it, did bundle install and got all the gems installed. When I try to do "rails server" I get an error:
=> Booting Mongrel
=> Rails 3.0.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/application/configuration.rb:86:in `read': No such file or directory - /Users/beatjunkie84/Desktop/Teamly/config/database.yml (Errno::ENOENT)
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/application/configuration.rb:86:in `database_configuration'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activerecord-3.0.1/lib/active_record/railtie.rb:58
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activesupport-3.0.1/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activerecord-3.0.1/lib/active_record/railtie.rb:57
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/initializable.rb:25:in `run'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/initializable.rb:50:in `run_initializers'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `each'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/application.rb:134:in `initialize!'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/application.rb:77:in `send'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/railties-3.0.1/lib/rails/application.rb:77:in `method_missing'
from /Users/beatjunkie84/Desktop/Teamly/config/environment.rb:5
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `polyglot_original_require'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/polyglot-0.3.1/lib/polyglot.rb:64:in `require'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `load_dependency'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `load_dependency'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
from /Users/beatjunkie84/Desktop/Teamly/config.ru:3
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
from /usr/local/rvm/gems/ruby-1.8.7-p302#rails301/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
from /Users/beatjunkie84/Desktop/Teamly/config.ru:1:in `new'
from /Users/beatjunkie84/Desktop/Teamly/config.ru:1
What can I do to fix this problem? I don't have a database.yml, which is the issue. However, neither did the repo when I cloned it. Why is it looking for a file that wasn't suppose to be there to begin with?
When people push their repo on github, they exclude configuration files from that repo. You'll need to create a database.yml file in order to make your application work.
Here's an example of it.
development:
adapter: mysql
database: bibapp_development
username: root
password:
test:
adapter: mysql
database: bibapp_test
username: root
password:
production:
adapter: mysql
database: bibapp_production
username: root
password: