Can't access Heroku console with app name - heroku

I just started a new app and I was able to push it to Heroku, But I it seems, that I can't access the console.
The command, that I am running is:
heroku run console --app myappname
What I get, is:
Running `console` attached to terminal... up, run.3951 Usage: rails
new APP_PATH [options]
Options: -r, [--ruby=PATH] # Path to the Ruby binary of
your choice
# Default: /app/vendor/ruby-1.9.3/bin/ruby -b, [--builder=BUILDER] #
Path to a application builder (can be a filesystem path or URL) -m,
[--template=TEMPLATE] # Path to an application template (can be a
filesystem path or URL)
[--skip-gemfile] # Don't create a Gemfile
[--skip-bundle] # Don't run bundle install -G, [--skip-git] # Skip Git ignores and keeps -O,
[--skip-active-record] # Skip Active Record files -S,
[--skip-sprockets] # Skip Sprockets files -d,
[--database=DATABASE] # Preconfigure for selected database
(options:
mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3 -j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript
library
# Default: jquery -J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository -T, [--skip-test-unit] # Skip
Test::Unit files
[--old-style-hash] # Force using old style hash (:foo = 'bar') on Ruby >= 1.9
Runtime options: -f, [--force] # Overwrite files that already
exist -p, [--pretend] # Run but do not make any changes -q,
[--quiet] # Suppress status output -s, [--skip] # Skip files
that already exist
Rails options: -h, [--help] # Show this help message and quit
-v, [--version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
I know, that the application name is correct, as I just pushed it and it is loaded.
When I look at the logs on Heroku for the moment, when I tried to hit the console, I see following:
2013-07-01T16:21:58.780979+00:00 heroku[api]: Starting process with command `bundle exec rails console` by mzaragoza#myemail.com
2013-07-01T16:22:09.000482+00:00 heroku[run.2993]: Awaiting client
2013-07-01T16:22:09.055474+00:00 heroku[run.2993]: Starting process with command `bundle exec rails console`
2013-07-01T16:22:10.342966+00:00 heroku[run.2993]: State changed from starting to up
2013-07-01T16:22:13.870963+00:00 heroku[run.2993]: Process exited with status 0
2013-07-01T16:22:13.889703+00:00 heroku[run.2993]: State changed from up to complete

What about heroku run rails c? Does it make any difference if you add rails?
PS: I'm unsure if you want to access Rails' console or just a normal shell, from the comments.

The correct form is => heroku run "any rails command here"

I had this problem when I upgraded to Rails > 4.0.0. The solution is to run locally the following command rake rails:update:bin. This will generate a bin directory in the root of your application. Make sure that it is not in your .gitignore file. Commit and then push the changes to Heroku.

For 3.2.x apps:
This also just happened to me when I removed script/rails from my repo and pushed to Heroku. Reverting the commit and pushing that change made things work again.

Related

Mina Deploy uses wrong user

I got some issue with the gem 'mina'. If I do set :user, 'username', he tries to connect to the server via Username#xxx.... wich is not working if the user is not existing. My PC is name Username. So mina setup and mina deploy are not working.
Does someone know a solution?.
Thanks
Best regards
Matze
EDIT:
Gemfile:
gem 'mina'
After that I run bundle install and mina init
deploy.rb:
require 'mina/rails'
require 'mina/git'
# require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
require 'mina/rvm' # for rvm support. (https://rvm.io)
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
set :user, "user"
set :application_name, 'appname'
set :domain, 'xx.xxx.xxx.xxx'
set :deploy_to, '/var/www/user/appname'
set :repository, 'user#xx.xxx.xxx.xxx:/home/user/git/appname.git'
set :branch, 'master'
# Optional settings:
# set :user, 'user' # Username in the server to SSH to.
# set :port, '30000' # SSH port number.
# set :forward_agent, true # SSH forward_agent.
# Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step.
# Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more
# run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files`
# set :shared_dirs, fetch(:shared_dirs, []).push('public/assets')
set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml')
# This task is the environment that is loaded for all remote run commands, such as
# `mina deploy` or `mina rake`.
task :remote_environment do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
# invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version#gemset.
# invoke :'rvm:use', 'ruby-1.9.3-p125#default'
end
# Put any custom commands you need to run at setup
# All paths in `shared_dirs` and `shared_paths` will be created on their own.
task :setup do
# command %{rbenv install 2.3.0 --skip-existing}
end
desc "Deploys the current version to the server."
task :deploy do
# uncomment this line to make sure you pushed your local branch to the remote origin
# invoke :'git:ensure_pushed'
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :'deploy:cleanup'
on :launch do
in_path(fetch(:current_path)) do
command %{mkdir -p tmp/}
command %{touch tmp/restart.txt}
end
end
end
# you can use `run :local` to run tasks on local machine before of after the deploy scripts
# run(:local){ say 'done' }
end
# For help in making your deploy script, see the Mina documentation:
#
# - https://github.com/mina-deploy/mina/tree/master/docs
set :execution_mode, :exec if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
When I run now mina setup he print that:
$ mina setup
User#xx.xxx.xxx.xxx's password:
SSH Auth key working fine and git working fine he just puts User instead of user before the ip, what is not working because the user just exists with small letter. But my working machine is named User.

How disable assets compilation on heroku?

I'm trying to deploy my rails app to heroku using this turtorial:
https://devcenter.heroku.com/articles/getting-started-with-rails4
So, I use rails 4.1.1 and ruby 2.1.1
My Gemfile has gem 'rails_12factor', group: :production inside.
My application.rb:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
module Charticus
class Application Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end
I created file public/assets/manifest.yml
But when I deploy app to heroku - it compile all my js-files files to application.js and all css-files application.css. And I can't see it on app.heroku.com using firebug.
What I need to do with my configurations to see all my js and css files on app.heroku.com ?
How disable assets precompiling and minification on heroku?
Help me please!
Thanks
lib/tasks/assets.rake
Rake::Task["assets:precompile"].clear
namespace :assets do
task 'precompile' do
puts "Not pre-compiling assets..."
end
end
You are done.
I compare config/environments/development.rb and config/environments/production.rb.
And make production.rb asset configs like in development.rb:
Comment this lines:
config.serve_static_assets = false
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
Then:
Push my changes to git repo git push origin master
Push changes to heroku git push heroku master
Rails 4 applications have a manifest-*.json file, not a manifest.yml file. This file is typically generated when you run rake assets:precompile , how are you compiling your assets?
Regardless, you need a file public/assets/manifest-(fingerprint).json file
Fast forward to 2018, and you would need to add the following to config/initializers/production.rb:
config.assets.enabled = false
Then you'd need to customize Heroku's Ruby Buildpack to not run the assets:precompile rake task. I won't provide a link to such a buildpack because I won't support or warrant one, but its pretty easy to find it in lib/language_pack/ruby.rb and start removing relevant code.
You'd then have to configure your Heroku app to use your new forked Buildpack instead of the default one (e.g. using heroku buildpacks).
Thats the cleanest way to disable the asset pipeline in a Heroku app w/ Rails, without resorting to overriding Rails' built-in rake tasks.
Fast forward to 2021 and Rails 6.x, if you completely removed Webpacker and Sprockets/Asset Pipeline, replace the bin/yarn file content with something like:
#!/usr/bin/env ruby
puts 'Yarn not present, nothing to do.'
#danielricecodes's advice is probably still valid but way more invasive.

Sidekiq server not loading configuration file

I'm trying to setup sidekiq with my sinatra application, and I'm having
trouble starting up the sidekiq workers to run in the daemon mode, with a configuration file.
My project has the following structure:
project
- config
-- sidekiq.yml #Sidekiq Config File
- app
-- app.rb #Sinatra Application File
- Rakefile
- Gemfile
- etc.
The ultimate goal is to create some rake tasks to handle all sidekiq tasks.
For now, I'm just trying to the get things to work correctly via the command line, and then I'll get it working via rake.
sidekiq.yml
# Sidekiq Configuration
---
development:
logile: ./log/sidekiq_development.log
verbose: true
pidfile: ./tmp/pids/sidekiq.pid
concurrency: 1
queues:
- [household_import, 7]
When I run this command in the project directory:
bundle exec sidekiq -C './config/sidekiq.yml' -e 'development' -d
I get the following:
You really should set a logfile if you're going to daemonize
/Users/gutter007/git/webapps/project/vendor/bundle/gems/sidekiq-2.16.1/lib/sidekiq/cli.rb:141:in
`daemonize'
/Users/gutter007/git/webapps/project/vendor/bundle/gems/sidekiq-2.16.1/lib/sidekiq/cli.rb:39:in
`parse'
/Users/gutter007/git/webapps/project/vendor/bundle/gems/sidekiq-2.16.1/bin/sidekiq:7:in
`<top (required)>'
/Users/gutter007/git/webapps/project/vendor/bundle/bin/sidekiq:23:in
`load'
/Users/gutter007/git/webapps/project/vendor/bundle/bin/sidekiq:23:in
`<main>'
My confusion is that I have the logfile set in the config file. My assumption is that it's not picking up or reading the cofig file correctly.
I tried tweaking the paths, and using full paths with the config file, but it did not seem to change anything the error message. I've also tweaked the config file itself, assuming the format might be off, but no dice.
Does anyone see what I'm doing wrong here?
Please let me know if you need any more information.
thanks.
I dug into the sidekiq code, and debugged my config file issues.
There were two issues:
I spelled logfile incorrectly ... doh!
You need to setup each row
with a colon(:) to symbolize the value. It pulls the yaml file into
a hash, and without the symbol it won't recognize the key
So
development:
logfile: ./log/sidekiq_development.log
won't work, but
development:
:logfile: ./log/sidekiq_development.log
#notice the ':' infront of the logfile
does!
Here is my updated working logfile.
# Sidekiq Configuration
---
development:
:logfile: ./log/sidekiq_development.log
:verbose: true
:pidfile: ./log/tmp/pids/sidekiq.pid
:concurrency: 1
:queues:
- [household_import, 7]
Following command helped me,
sidekiq -d -q carrierwave -l sidekiq.log
you can omit "-q carrierwave" part, if yuo're not using 'carrierwave'

Getting Heroku to precompile assets to Amazon aws s3

Almost there with my issue of getting AWS S3 to serve my heroku app its static assets
Everything works locally, i run my rake task and then the assets get precompiled to AWS ( though there is never any output in the terminal?)
Then to heroku, where i set my ENV variables like so
heroku config:add aws_access_key=mysecretkey aws_secret_key=mypublickey aws_bucket=mybucketname
I have two buckets, one for dev and one for production. Do i need to set anything else in the heroku:config?
Heres what i have so far
config.rb
AssetSync.configure do |con|
con.fog_provider = 'AWS'
con.fog_region = 'eu-west-1'
con.fog_directory = ENV['aws_bucket']
con.aws_access_key_id = ENV['aws_access_key']
con.aws_secret_access_key = ENV['aws_secret_key']
con.prefix = "assets"
con.public_path = Pathname("./public")
end
Question here, how much of this will heroku read and use, I know i have to set the ENV explicitly in heroku but will it read the rest and carry out the rest of the task, ie will it read prefix, public_path etc ?
Rakefile
require 'bundler/setup'
Bundler.require(:default)
require 'active_support/core_ext'
require './config/env' if File.exists?('config/env.rb')
require './config/config'
namespace :assets do
desc "Precompile assets"
task :precompile do
AssetSync.sync
end
end
When running
heroku run rake assets:precompile
i get the output
`rake assets:precompile` attached to terminal...up, run.2942 The source :rubygems is deprecated because HTTP requests are insecure. Please change your source to 'https://rubygems.org (in /app)
Then it just returns to the terminal, I expected a list of all the assets that where to be compiled listed as the task was being carried out. Upon checking my bucket in aws, it is empty
EDIT
Output after heroku logs --tail
2013-03-19T10:55:50+00:00 heroku[api]: Starting process with command `bundle exec rake assets:precompile` by richlewis14#gmail.com
2013-03-19T10:55:52+00:00 heroku[run.6701]: State changed from starting to up
2013-03-19T10:55:53+00:00 heroku[run.6701]: Awaiting client
2013-03-19T10:55:53+00:00 heroku[run.6701]: Starting process with command `bundle exec rake assets:precompile`
2013-03-19T10:55:59+00:00 heroku[run.6701]: Client connection closed. Sending SIGHUP to all processes
2013-03-19T10:56:00+00:00 heroku[run.6701]: Process exited with status 0
2013-03-19T10:56:00+00:00 heroku[run.6701]: State changed from up to complete
More was added after about 15 minutes
! Heroku client internal error.
! Search for help at: https://help.heroku.com
! Or report a bug at: https://github.com/heroku/heroku/issues/new
Error: An existing connection was forcibly closed by the remote host
(Errno::ECONNRESET)
Command: heroku logs --tail
Version: heroku-gem/2.35.0 (i386-mingw32) ruby/1.9.3
This is a bundler error due to the source stated in the Gemfile. It is not related to the asset compilation per se.
Specify
source 'https://rubygems.org'
at the top of your Gemfile.

Setting up rake-pipeline for use with handlebars alongside Google App Engine

So here's what I'm attempting to do. I'm building an ember.js application, with a java backend running on GAE.
I'm using handlebars, but I want them divided up into separate files, not just all pasted into the index.html.
Via the ember.js irc I was turned on to rake-pipeline along with minispade
Along with the web filters and a custom handlebars filter I started building the assetfile. I don't know Ruby, or gem files, etc.
So I'm trying to figure out the best way to be able to compile my coffeescript/handlebars files on the fly, minispade them, but keep the individual files accessible while in dev mode so I can debug them. What makes that hard is that the rake pipeline is running on a different port than GAE. So I'm not sure exactly how to handle this. Do I make my index file in GAE point to individual files at the 9292 port (rakep) during development, but in production mode point to the fully concatenated version? I'm not sure.
So I was attempting to do that here: https://gist.github.com/1495740 by having only one section that was triggered by the 'build' flag. Not even sure if that works that way.
I know there's a lot of confusion here. Apologies, like I said I'm not even remotely familiar with the Ruby style of doing things.
Since you're not a Ruby person, here are the most reliable steps for getting a stock OSX environment set up with rake pipeline:
Step 1: Install bundler
# on OSX, using built-in Ruby
$ sudo gem install bundler --pre
Step 2: Create a Gemfile
# inside your app directory
$ bundle init
# will create a file named Gemfile in the root
Step 3: Add rake-pipeline to the Gemfile
# inside the Gemfile
gem "rake-pipeline-web-filters"
Step 4: Install your gems
$ bundle install --binstubs
Step 5: Set up Assetfile
However you were already doing it...
Step 6: Run Rake::Pipeline
# to run the preview server
$ bin/rakep
# to build your assets
$ bin/rakep build
Rake::Pipeline.build is the method that evaluates an Assetfile. You can imagine that your entire Assetfile is wrapped inside a Rake::Pipeline.build {} block; you shouldn't ever need to write one inside an Assetfile.
Some of the filters in the docs are hypothetical, most of those docs were written before there were any filters at all. A CoffeeScript compiler has been recently added, though.
As to your main question, I'm not sure there's a clean way to do it with the current rakep implementation. An Assetfile is just Ruby, though, so it's possible to hack something together that should work. Here's how I would write yours:
require "json"
require "rake-pipeline-web-filters"
require "rake-pipeline-web-filters/helpers"
class HandlebarsFilter < Rake::Pipeline::Filter
def initialize(&block)
block ||= proc { |input| input.sub(/\.handlebars$/, '.js') }
super(&block)
end
def generate_output(inputs, output)
inputs.each do |input|
output.write "return Ember.Handlebars.compile(#{input.read.to_json})"
end
end
end
# process all js, css and html files in app/assets
input "assets"
# processed files should be outputted to public
output "public"
# process all coffee files
match "**/*.coffee" do
# compile all CoffeeScript files. the output file
# for the compilation should be the input name
# with the .coffee extension replaced with .js
coffee_script
# The coffee_script helper is exactly equivalent to:
# filter Rake::Pipeline::Web::Filters::CoffeeScriptCompiler
end
match "**/*.js" do
minispade
if ENV['RAKEP_ENV'] == "production"
concat "application.js"
else
concat
end
end
match "**/*.handlebars" do
filter HandlebarsFilter
minispade
concat "templates.js"
end
The if ENV['RAKEP_ENV'] bit reads an environment variable to decide whether to concatenate your JS to a single file.
So now you can run RAKEP_ENV="production" rakep build for a concatenated build, or just rakep build for a development build.

Resources