Heroku deploy error: couldn't find HOME environment -- expanding `~' - ruby-on-rails

I am attempting to deploy my Rails 4 app to Heroku, and when I enter:
git push heroku master
I get the following error:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
From the Rails Asset Pipeline on Heroku Cedar:
This means that your app is attempting to connect to the database as part of rake assets:precompile. Because the config vars are not present in the environment and this is the mechanism the Heroku uses to configure your database connection, the command is failing.
The page suggests that I run
env -i GEM_PATH=$GEM_PATH \
PATH=$PATH \
DATABASE_URL=postgres://user:pass#127.0.0.1/dbname \
/bin/sh -c 'bundle exec rake --trace assets:precompile'
When I do, I get the following error:
rake aborted!
couldn't find HOME environment -- expanding ~'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/guardfile/generator.rb:20:inexpand_path'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/guardfile/generator.rb:20:in <class:Generator>'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/guardfile/generator.rb:9:in'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/guardfile/generator.rb:2:in <module:Guard>'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/guardfile/generator.rb:1:in'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/guardfile.rb:2:in require'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/guardfile.rb:2:in'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/dsl.rb:1:in require'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard/dsl.rb:1:in'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard.rb:6:in require'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-2.2.4/lib/guard.rb:6:in'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-rspec-4.2.0/lib/guard/rspec.rb:1:in require'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/guard-rspec-4.2.0/lib/guard/rspec.rb:1:in'
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:81:in require'
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:81:inrescue in block in require'
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:66:in block in require'
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:ineach'
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in require'
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:132:inrequire'
/Users/dmanaster1/flatiron_school/SourceQ-An/config/application.rb:5:in <top (required)>'
/Users/dmanaster1/flatiron_school/SourceQ-An/Rakefile:5:inrequire'
/Users/dmanaster1/flatiron_school/SourceQ-An/Rakefile:5:in <top (required)>'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:inload'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in load_rakefile'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:637:inraw_load_rakefile'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:94:in block in load_rakefile'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:instandard_exception_handling'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:93:in load_rakefile'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:77:inblock in run'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in standard_exception_handling'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:inrun'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/gems/rake-10.1.0/bin/rake:33:in <top (required)>'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/bin/rake:23:inload'
/Users/dmanaster1/flatiron_school/SourceQ-An/vendor/cache/ruby/2.0.0/bin/rake:23:in `'
What is generating this error? How can I fix it?

I am unfamiliar with user-env-compile, but just set the Devise key as described here:
heroku config:set DEVISE_SECRET_KEY=whatever_the_key_is
Make sure your initializer then uses the key like this:
config.secret_key = ENV['DEVISE_SECRET_KEY']
Then disable user-env-compile like so:
heroku labs:disable user-env-compile -a myapp
And then try to deploy.

Related

Scalelite Nginx Not loading

<returncode>FAILED</returncode>
<messageKey>unsupportedRequest</messageKey>
<message>This request is not supported.</message>
</response>```
This is the response from the scalelite server when i enter the URL on browser.
I am getting this message when i try to run
```docker exec -i scalelite-api bundle exec rake db:setup```
ActiveRecord::ProtectedEnvironmentError: You are attempting to run a destructive action against your 'production' database.
If you are sure you want to continue, run the same command with the environment variable:
DISABLE_DATABASE_ENVIRONMENT_CHECK=1
/srv/scalelite/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.6/lib/active_record/tasks/database_tasks.rb:63:in `check_protected_environments!'
/srv/scalelite/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.6/lib/active_record/railties/databases.rake:15:in `block (2 levels) in <main>'
/srv/scalelite/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.3.6/lib/active_record/railties/databases.rake:404:in `block (3 levels) in <main>'
/srv/scalelite/vendor/bundle/ruby/2.6.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/usr/bin/bundle:23:in `load'
/usr/bin/bundle:23:in `<main>'
Tasks: TOP => db:schema:load => db:check_protected_environments
(See full trace by running task with --trace)
This is what i get when i enter the command
docker exec -i scalelite-api bundle exec rake status
domain.com enabled online 0 0 0 0
domain.com enabled online 0 0 0 0
Experts please help me with this. I am new to this
I am trying the balance the load between 2 servers.
That's OK. You should check it with https://your.scalelite.com/bigbluebutton/api/ not https://your.scalelite.com.

Errno::ENOENT: No such file or directory - osascript

I have a Rails app which i am trying to deploy in Ubuntu 18.04 LTS Linux. bundle install run ok but when I run bundle exec rake secret it shows Errno::ENOENT: No such file or directory - osascript
myappuser#ubuntu:/var/www/myapp/code$ bundle exec rake secret
rake aborted!
Errno::ENOENT: No such file or directory - osascript
/home/myappuser/.rvm/gems/ruby-2.5.0/gems/webconsole-0.2.1/lib/webconsole/lib/module.rb:95:in ``'
/home/myappuser/.rvm/gems/ruby-2.5.0/gems/webconsole-0.2.1/lib/webconsole/lib/module.rb:95:in `run_applescript'
/home/myappuser/.rvm/gems/ruby-2.5.0/gems/webconsole-0.2.1/lib/webconsole/lib/module.rb:10:in `application_exists'
/home/myappuser/.rvm/gems/ruby-2.5.0/gems/webconsole-0.2.1/lib/webconsole.rb:9:in `<top (required)>'
/var/www/myapp/code/config/application.rb:7:in `<top (required)>'
/var/www/myapp/code/Rakefile:5:in `require'
/var/www/myapp/code/Rakefile:5:in `<top (required)>'
/home/myappuser/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `eval'
/home/myappuser/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `<main>'
(See full trace by running task with --trace)
Need help.
webconsole is trying to run osascript, which is macOS-specific and not available on Linux. You can replace gem 'webconsole' in your Gemfile with the following to only use it on macOS:
gem 'webconsole' if RUBY_PLATFORM.match?(/darwin/)

Cannot migrate on Heroku

I'd like to migrate database to production environment on Heroku.
I typed the following code, however I got error. I have no idea what to do. I'm looking forward to your advice. Thank you for your kindness.
$ heroku run rake db:migrate
Running `rake db:migrate --trace` attached to terminal... up, run.2338
rake aborted!
LoadError: libruby.so.2.2: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.2/lib/pg_ext.so
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/pg-0.18.2/lib/pg.rb:4:in `<top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:72:in `block in require'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:61:in `require'
/app/vendor/bundle/ruby/2.2.0/gems/bundler-1.9.7/lib/bundler.rb:134:in `require'
/app/config/application.rb:7:in `<top (required)>'
/app/Rakefile:4:in `require'
/app/Rakefile:4:in `<top (required)>'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_module.rb:28:in `load_rakefile'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:689:in `raw_load_rakefile'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:94:in `block in load_rakefile'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:93:in `load_rakefile'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:77:in `block in run'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/app/vendor/ruby-2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/app/bin/rake:8:in `<main>'
Have you tried running migration directly from the bash inside the heroku server? If not, try the following...
heroku run bash --app your_app_name_goes_here
bundle exec rake db:migrate
First line of code opens the bash command terminal and the second one migrates the db as usual.
This would not be the suggested solution. But, in case you DO NOT care about losing data in the database, you can try and reset the database first and try again. Again, don't do this unless you are willing to lose existing data!
heroku pg:reset DATABASE
heroku run rake db:migrate
However you can perform this via bash as before.
Hope this helps you out.
You can run a dyno in the background using heroku run:detached. Unlike heroku run, these dynos will send their output to your logs instead of your console window. You can use heroku logs to view the output from these commands:$ heroku run:detached rake db:migrate
Running rake db:migrate... up, run.2
Use 'heroku logs -p run.2' to view the log output.

DEPRECATION WARNING while using bundle install

So I am trying to do bundle install . But it is throwing the below errors. What is the problem here?
bundle exec rake db:create:all
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:66)
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:67)
rake aborted!
Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)
Earlier I had tried the below:
rake db:create:all
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/runtime.rb:34:in `block in setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/runtime.rb:19:in `setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler.rb:122:in `setup'
/home/.gem/ruby/2.1.3/gems/bundler-1.7.12/lib/bundler/setup.rb:7:in `<top (required)>'
/home/project/config/boot.rb:4:in `<top (required)>'
/home/project/config/application.rb:1:in `<top (required)>'
/home/project/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/project/config/boot.rb:4:in `<top (required)>'
/home/project/config/application.rb:1:in `<top (required)>'
/home/project/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
$ bundle exec rake db:create:all
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:66)
DEPRECATION WARNING: String based terminators are deprecated, please use a lambda. (called from included at /home/.gem/ruby/2.1.3/bundler/gems/authlogic-09163c7d2a9b/lib/authlogic/session/callbacks.rb:67)
rake aborted!
Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
/home/.gem/ruby/2.1.3/gems/activerecord-4.1.5/lib/active_record/railtie.rb:43:in `block (3 levels) in <class:Railtie>'
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)
You are trying to run "rake db:create:all" which would create your database but as error states - it seems you don't have your config/database.yml file. It's a configuration file that tells rails how to connect to your database. You can read more about it here.
If you really want to run bundle install, just use "bundle install" command instead. This will install all gems listed in your Gemfile.
If you will get problems with rake version conflicts, check out this stack overflow question.
It seems you have no config/database.yml file in your project's directory.
Why I think so? Follow me ...
Could not load database configuration. No such file -
/home/.gem/ruby/2.1.3/gems/railties-4.1.5/lib/rails/application/configuration.rb:105:in `database_configuration'
Ok, let's take a look at this code where we have error:
yaml = Pathname.new(paths["config/database"].existent.first || "")
config = if yaml.exist?
require "yaml"
require "erb"
YAML.load(ERB.new(yaml.read).result) || {}
elsif ENV['DATABASE_URL']
# Value from ENV['DATABASE_URL'] is set to default database connection
# by Active Record.
{}
else
raise "Could not load database configuration. No such file - #{yaml}"
end
As you can see - if no such file or ENV variable then rails throws error.

Why do I get a "Library not loaded: libmysqlclient.18.dylib" error?

I have been following a video tutorial and the database is created, but when trying to follow the step by going to directory and entering rake: dbmigrate
I get an error.
Ians-MacBook-Pro:music_library iansherwood$ rake db migrate
rake aborted!
dlopen(/Users/iansherwood/Sites/music_library/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.13/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/iansherwood/Sites/music_library/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.13/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/iansherwood/Sites/music_library/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.13/lib/mysql2/mysql2.bundle
/Users/iansherwood/Sites/music_library/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require'
/Users/iansherwood/Sites/music_library/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.2.4/lib/bundler/runtime.rb:68:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.2.4/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.2.4/lib/bundler/runtime.rb:66:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.2.4/lib/bundler/runtime.rb:66:in `block in require'
/usr/local/rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.2.4/lib/bundler/runtime.rb:55:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.2.4/lib/bundler/runtime.rb:55:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.2.4/lib/bundler.rb:128:in `require'
/Users/iansherwood/Sites/music_library/config/application.rb:7:in `<top (required)>'
/Users/iansherwood/Sites/music_library/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
Have you tried bundle exec rake db:migrate?
Another possibility is that you don't have my MySQL running.
The easiest way to check for that would be:
ps aux | grep mysql
If it isn't running and you installed MySQL through
homebrew (common video guide way to install it) then you can run mysql.server start.
The syntax should be: rake db:migrate, and not rake: dbmigrate or rake db migrate.
It looks like your colon use might be inconsistent. Remember to use:
rake db:migrate
http://guides.rubyonrails.org/command_line.html
Did you include "gem 'mysql2'" in your Gemfile?

Resources