I have a new Rails 5 app. I installed the spring and spring-commands-rspec gems as specified in their directions. I can run rspec by itself and the tests run fine. However, if I run the Spring binstub bin/rspec I get this:
Running via Spring preloader in process 227
/usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `new'
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `connect'
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:217:in `initialize'
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `new'
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
etc...
I have a Rails 4 app that uses the binstubs and bin/rspec works great. What gives?
Incidentally, rake spec fails the same way, with that database connection error.
Embarrassing. I had not set up my database.yml properly to inherit settings from *default, so the message above literally was telling me there was no database running. Once I got that fixed, the binstub worked again.
Related
I'm trying to learn rails but I'm having this problem to set up the connection between postgresql and rails. I have follow several tutorials but none of those have worked for me, as far as i know this issues has to do with the configuration i need to add on my database.yml.
If you're sure the username and password are accurate. You can just have them in the default block to avoid duplicating them in the development and test block and try again.
rake db:create
rake db:migrate
rails s
I'm trying create a app with ruby on rails in termux, I already installed the necessary gems and packages for the setup, but when doing rails db:create. I get this error
rails aborted!
ActiveRecord::ConnectionNotEstablished: connection to server on socket "/data/data/com.termux/files/usr/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Caused by:
PG::ConnectionBad: connection to server on socket "/data/data/com.termux/files/usr/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
You need to start a PostgreSQL server manually for your app to be able to connect to.
Install postgresql via pkg install postgresql
See the wiki for sample setup instructions https://wiki.termux.com/wiki/Postgresql
hope someone can help me here:
I have
* changed the database in my application from sqlit3 to postgresql,
* replaced the gemfile to gem 'pg',
* update database.yml
all this, in order to be able to deploy to heroku.
when I run
rake db:setup
I am getting these errors:
DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
>> Coffee::Rails::TemplateHandler.call(template)
To:
>> Coffee::Rails::TemplateHandler.call(template, source)
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Couldn't create 'school-grades-project' database. Please check your configuration.
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I read that jbuilder should take care on the issue, so I upgraded jbuilder, but still the problem remains.
would appreciate some help here.
thanks,
It's a bit hard to diagnose this because you didn't specify the version of Rails that you're using or the contents of your database.yml file. But assuming it's a recent Rails version with support for database URLs it should work by following the descriptions in the Getting started guide for Rails.
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="postgres://myuser:mypass#localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
Did you uncomment the production settings?
Here I have a quick solution.
This issue came into existence after updating the application to rails 6.x, To resolve it update the following gems:
Updating coffee-rails to 5.0.0 fixed this for me
Then run the bundle update and start the application server solved the warning issue.
I'm new to Rails so please bear with me.
Currently there is an existing project (Rails 4.1.6, Ruby 2.1.3) running on digital ocean VM (Ubuntu 14.04) and its connecting to Postgresdb 9.6 without any issues. I have to migrate this to new VM.
I have setup a new vm with Ubuntu 16.04, installed Rails and Ruby with exact same versions. I tried creating a test rails app and its working fine. However, when I tried to deployed the project from old server to this new one its giving me errors.
Details:
There was an error while trying to load the gem 'uglifier'.
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs /runtimes.rb:58:in `autodetect'
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib /active_support/dependencies.rb:247:in `require'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
After searching on internet, most of them suggested to uncomment this line in the Gemfile.
# gem 'therubyracer', platforms: :ruby
This was commented in the old server, however, I tried uncommenting it and it came back with different error.
Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development
Website was connecting to the same database and old webportal was running fine but it gave me this error. So I setup a new test db and ran the following commands -
RAILS_ENV=production bundle exec rake db:create
RAILS_ENV=production bundle exec rake db:setup
RAILS_ENV=production bundle exec rake db:migrate
All those commands were executed successfully but for some reason I'm still receiving "Migrations are pending....." error.
Please advise.
The migration-error seems to think you should be on the development environment... but the migrations you ran are for production... so either your environment-setting is not correct, or you need to run the migrations for development instead
I have a longstanding project that is using sidekiq with redis and a problem that has started I believe only since upgrading to sidekiq 3+.
The problem is that I can't run my rails (4.1.4) app in development without first starting a redis server. I get the same error starting the rails server as I get when I try to run bundle exec sidekiq without first starting redis. Running my rails app without redis running was never a problem before, even though sidekiq was setup the same way.
Can someone suggest a way around having to start a redis server even when I don't intend to run sidekiq?
Here is the backtrace:
/Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:309:in
rescue in establish_connection': Error connecting to Redis on
127.0.0.1:6379 (ECONNREFUSED) (Redis::CannotConnectError) from /Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:304:in
establish_connection' from
/Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:85:in
block in connect' from
/Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:266:in
with_reconnect' from
/Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:84:in
connect' from
/Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:326:in
ensure_connected' from
/Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:197:in
block in process' from
/Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:279:in
logging' from
I think this problem is related to https://github.com/tobiassvn/sidetiq/issues/103.
Unfortunately, the fix has not been pulled into the main repo yet. You can try using the fixed fork in your Gemfile to see if it fixes the problem:
gem 'sidetiq', github: 'nkondratyev/sidetiq', branch: 'fix_working_with_prefork_servers'