Errors in starting rails server - ruby-on-rails

I created a rails site with the *rails new {project_name} -d mysql*
and then cd to the project_name and ran the rails server command but got the error below, what could be the problem? Anyone knows? do i have to change the mode 040777? if yes, how? thanks
/Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9
from /Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /Users/henryjoseph/Sites/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:53
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.13/lib/rails/commands.rb:50
from script/rails:6:in `require'
from script/rails:6

cd ur_dir
then you have to connect your mysql database to your project.
for this you see the config/database.yml file where you have to add this
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: your_database_name
pool: 5
username: your_db_username
password: ur_db_password
host: localhost
then rails s

Related

Can't create model on ruby on rails

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

How to resolve this sqlite issue with my rails app?

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...

Rails App Won't Start in Production Environment because of ActiveRecord

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)

Rails Server crashing upon running getting "no such file or directory"

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:

Rails server won't run with mysql2 gem

**I know this is a popular issue here, but I just can't seem to get it to run. I've tried just about everything I've read, and the issue persist.
I'm using RVM and 1.9.2. I'm also using MySQL 5.5, and I've reinstalled it several times. My installation of Ruby seems to work well with SQLite, but it chokes on MySQL. I've checked to see if MySQL is working through PHP too, so I know that's not the issue. Rails just can't seem to find the "libmysqlclient.18.dylib" file.
Here's what happens when I run the server:**
littleMac$ sudo rails s
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /Users/littleMac in PATH, mode 040777
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /Users/littleMac in PATH, mode 040777
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `require': dlopen(/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `<top (required)>'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
from /Users/littleMac/sites/TestBox2/config/application.rb:7:in `<top (required)>'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
If you are using RVM chances are you don't want to sudo.
Please also format your code in a code block to make it easier for people to help.
Read this post. It seems to be identical.

Resources