I am deploying a rails app on a AWS ec2 instance through Capistrano.
Cap production deploy:check is successful, but when I am running cap production deploy I get an error.
Can anyone help?
I found the problem. Your Gemfile in the project was named "gemfile" SMALL g
It must be Gemfile.
So the thing run on Mac and Windows. But when you deploy to Linux, it does not see the Gemfile.Please rename the "gemfile" in your project to "Gemfile"
It will work.
I need help. When trying to upload my app to heroku, I get this error, anyone know why? A few was wrong. thanks
Using rake (10.1.0)
...
Using tlsmail (0.0.1)
Using uglifier (2.1.2)
Your bundle is complete! It was installed into ./vendor/bundle
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/tlsmail-0.0.1/lib/net/smtp.rb:806: warning: already initialized constant SMTPSession
...
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/tlsmail-0.0.1/lib/net/pop.rb:702: warning: already initialized constant APOPSession
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/Rakefile:7)
...
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?
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
...
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
From the Heroku docs:
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, we use a placeholder DATABASE_URL to satisfy Rails.
To resolve this issue, ensure that the following line appears in your config/application.rb:
# config/application.rb
config.assets.initialize_on_precompile = false
Once added, commit your change and redeploy to Heroku – your assets should compile without your app attempting to connect to the database, which should resolve the error you're witnessing.
UPDATE:
Line 46 of your stacktrace includes the following message: Devise.secret_key was not set.
According to the author of Devise, José Valim, this issue can be resolved in the following manner:
Please add the following to your Devise initializer:
config.secret_key = '-- secret key --'
Alternatively, the following solution seems to have worked for a number of users:
I went to my routes.rb file and commented out the line devise_for :installs
Then I went back and reran rails generate devise:install. If that doesn't work, use the previous version of devise by editing your Gemfile's reference to Devise like this: gem 'devise', '3.0.3' and then follow the steps i mentioned above.
There a few things that solved this issue for me:
# config/application.rb
config.assets.initialize_on_precompile = false
Then, before I deployed, I compiled my assets locally and committed them:
RAILS_ENV=production bundle exec rake assets:precompile
Also, I installed this heroku add on, as was specified by the app I was launching (in my case, Spree commerce)
heroku labs:enable user-env-compile -a myapp
And of course, make sure your database.yml file is set to use adapter: postgresql.
Commit all of this, push to heroku, and hopefully it will launch. If you still cannot open your app, try looking at the Heroku logs: heroku logs -n 500
I still needed to migrate my database with heroku run rake db:migrate
when you are using github and you are pushing to heroku while you are in develop branch, dont do it, go to master branch and get the updates in the develop by git merge develop
after that,
rails precompile:assets
git add -A
git commit -m "Precompile assets"
git push heroku master
if you want to open the website that you deployed
heroku open
if nothing shows, migrate your database first by:
heroku run rails db:migrate
heroku open
I have failed Heroku proceompiling with same error message.
Carrierwave causes that because I have missed set up SECRET_KEY_BASE to Heroku setting.
I decided to serve rails assets via S3; heroku has great tutorials on how to do this. The site is now serving assets from my amazon bucket but I'm unsure why I had to manually run heroku run rake assets:precompile after a git push heroku master which runs a rake assets:precompile.
After running the git push heroku master the assets where not in my bucket and the output for the precompile stuff was:
AssetSync: using default configuration from built-in initializer
AssetSync: using default configuration from built-in initializer
rake aborted!
Fog provider can't be blank, Fog directory can't be blank
/tmp/build_3vtwfg15g8ajx/vendor/bundle/ruby/1.9.1/gems/asset_sync-0.5.0/lib/asset_sync/asset_sync.rb:29:in `sync'
/tmp/build_3vtwfg15g8ajx/vendor/bundle/ruby/1.9.1/gems/asset_sync-0.5.0/lib/tasks/asset_sync.rake:3:in `block in <top (required)>'
Tasks: TOP => assets:precompile:nondigest
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
I did set the fog provider and directory with: heroku config:add FOG_DIRECTORY=XXX FOD_PROVIDER=AWS and calling heroku config --app confirms this...so I don't get those errors.
The assets didn't show up in my bucket so I ran: heroku run rake assets:precompile and everything worked with a warning:
AssetSync: using default configuration from built-in initializer
AssetSync: Syncing.
[WARNING] fog: the specified s3 bucket name(ss_assets) is not a valid dns name, which will negatively impact performance. For details see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/Bucket
Restrictions.html
Will I always have to run the precompile task after and just be okay with the push failure? I'll check to see if the Warning of the directory name is causing the blank FOG errors on push
EDIT
Again asset_sync doesn't appear to have ENV variables when called in the assets:precompile task of the heroku push. Running that task after push works but it 'annoying'.
Still not working for me, latest attempt was (per asset_sync github project):
lib/tasks/asset_sync.rake.
Rake::Task['assets:precompile'].enhance do
AssetSync.sync
end
Rake::Task["assets:precompile:nondigest"].enhance do
AssetSync.sync
end
I also attempted adding lines to my production.rb file such as:
config.asset_sync.aws_bucket = ENV['FOG_DIRECTORY']
config.asset_sync.fog_provider = ENV['FOG_PROVIDER']
Didn't work for me either.
run below from asset_sync docs Labs section
heroku labs:enable user-env-compile -a myapp
Hasn't made it's way into the platform as standard yet!
I'm getting this error when I push to Heroku:
Running: rake assets:precompile
rake aborted!
You did not provide both required access keys. Please provide the access_key_id and the secret_access_key.
but, my keys are there
$ heroku config
AMAZON_ACCESS_KEY_ID => SOMethingSecRET
AMAZON_SECRET_ACCESS_KEY => EVENmoreSecret/sTuff//PASSworD
and my S3 connection is defined in config/initializer/s3.rb
AWS::S3::Base.establish_connection!(
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
)
Yet Heroku somehow REFUSES to read them. Even heroku's own docs tell you to do it this way: http://devcenter.heroku.com/articles/config-vars
I've literally read through and tried all of the suggested "solutions" on here about getting Heroku to read s3 access keys, but they all deal with Paperclip and none require an initializer.
Relevant info: Rails 3.1, Cedar Stack
What the hell Heroku?
If you're getting this error during the deploy process, this is because the slug compilers don't have access to your environment (where your config vars are set).
There's two options:
1) Make the asset precompile code fail silently and run it once the deploy is complete and your environment is available.
2) Use the user_env_compile lab add-on
$ heroku plugins:install http://github.com/heroku/heroku-labs.git
$ heroku labs:enable user_env_compile -a myapp
-----> Enabling user_env_compile for myapp... done
WARNING: This feature is experimental and may change or be removed without notice.
I'm running Rails + Passenger under an Ubuntu AWS's instance. Now I'm trying to deploy with Capistrano, I already did my git repository (and upload it to the server) and my deploy.rb file (with capify .). I already runned cap deploy:setup and cap deploy:check with success. But now when I try to run cap deploy it fail and I get this error http://pastebin.com/uzkerA9F
Well, I found the problem and solution here
Capistrano asks for password when deploying, despite SSH keys
So > I add set :ssh_options, {:forward_agent => true} to my deploy.rb file