Rake assets:precompile fails with: couldn't find file 'handlebars' - ember.js

Running the command during a capistrano deploy:
bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile
returns
rake aborted!
couldn't find file 'handlebars'
(in */app/assets/javascripts/application.js:22)
*/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:102:in `resolve'
*/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:142:in `require_asset'
*************
Tasks: TOP => assets:precompile:all
Gem ember-rails is in a global scope in my Gemfile and I am using handlebars-source (1.0.12), ember-rails (0.12.0), ember-source (1.0.0.rc6.2) in Rails 3.2.12 and ruby 1.9.3.
It's probably worth noting that this works in production, but not in staging deploys.
Also I have the following in my staging.rb, which appears to be the common issue.
config.ember.variant = :production

Turns out I had added the line
config.ember.variant = :development
to a version that wasn't getting pushed to master. Added config.ember.variant = :development to the current version fixed this.

Related

Rails: How to set up db:schema:load for initial deploy with Capistrano

I'm trying to deploy my Rails 4 app using Capistrano 3. I'm getting error messages in running the db:migrations (i've been sloppy, sorry). Is there a way to have Capistrano deploy the app (at least the first time) using db:schema:load?
An excerpt of my deploy.rb:
namespace :deploy do
%w[start stop restart].each do |command|
desc 'Manage Unicorn'
task command do
on roles(:app), in: :sequence, wait: 1 do
execute "/etc/init.d/unicorn_#{fetch(:application)} #{command}"
end
end
end
I'm not sure how to override Capistrano 3's default behaviour. Can someone tell me how to add this to my script?
For first time deploys, I generally hack around it by logging into the server, cding into the release directory (which will have the deployed code at this point), and then manually running RAILS_ENV=yourenv bundle exec rake db:setup.
In Capistrano 3.10.1 with a Rails 5.1.6 application,
~/Documents/p.rails/perla-uy[staging]$ bundle exec cap staging deploy:updating
gives me enough to shell-in and run the db:structure:load or db:schema:load task manually. In the secure shell session to the host, switch to the newly created release directory and:
dclo#localhost:~/perla-uy/releases/20180412133715$ bundle install --without development test --deployment
dclo#localhost:~/perla-uy/releases/20180412133715$ bundle exec rails db:schema:load
Shelling into a (successful or failed) deploy that has tried deploy:migrate isn't quite the same.
Note: I have RAILS_ENV=production and RAILS_MASTER_KEY=... set-up by the shell login.

ROR + Run Rake Job automatically after deployment

In Rails deployment, some times we missed to execute rake db:migrate, rake db:seed or any rake job after deploying the project at regular interval. I am trying to add such script with Rails structure, which will call RakeJob and all such type of script automatically after deployment.
Just like in this sequential way :-
rake db:migrate
rake db:seed
rake ( Here Rake is the combination of all rake jobs )
I normally deploy to Heroku. I am not sure where you are deploying to but here is a copy of my deploy script
#vim lib/tasks/deploy.rake
namespace :deploy do
#rake deploy:production # Deploy to production
desc "Deploy to production"
task :production do
puts "THIS IS DEPLOYING TO PRODUCTION!!!"
puts "********* CAREFUL! *********"
sleep 10
backup_environment_db("heroku-prod")
deploy_sha_to_environment(ARGV[1], "heroku-prod")
system("open http://www.example.com/")
end
def deploy_sha_to_environment(sha, environment)
if sha = ARGV[1]
puts "About to push #{sha} to #{environment}."
message = `git log --format=%B -n 1 #{sha}`
puts "#{sha} -- #{message}"
sleep 2
Bundler.with_clean_env do
system "git push --force git#heroku.com:#{environment}.git #{sha}:master"
system "heroku run rake db:migrate --app #{environment}"
system "heroku restart --app #{environment}"
end
else
puts
puts "*** sha required! (pass it as an argument) ***"
puts
Rake.application.invoke_task("codeship:statuses")
exit
end
end
end
I hope that this helps

Can't run Rails in Gem/Engine project without first installing the gem itself

I just made a fresh checkout of my Rails Engine project, and when (after bundle install) I invoke rails -v in its root directory, I'm getting a LoadError in which Rails appears to be looking for the very gem/engine I'm trying to build:
my-engine dmoles$ rails -v
/Users/dmoles/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'my-engine' (>= 0) among 117 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/dmoles/.rvm/gems/ruby-2.2.1:/Users/dmoles/.rvm/gems/ruby-2.2.1#global', execute `gem env` for more information
from /Users/dmoles/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:324:in `to_spec'
from /Users/dmoles/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /Users/dmoles/.rvm/gems/ruby-2.2.1/bin/rails:22:in `<main>'
Running gem env as suggested provides no more enlightenment:
my-engine dmoles$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.6
- RUBY VERSION: 2.2.1 (2015-02-26 patchlevel 85) [x86_64-darwin14]
- INSTALLATION DIRECTORY: /Users/dmoles/.rvm/gems/ruby-2.2.1
- RUBY EXECUTABLE: /Users/dmoles/.rvm/rubies/ruby-2.2.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/dmoles/.rvm/gems/ruby-2.2.1/bin
- SPEC CACHE DIRECTORY: /Users/dmoles/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/dmoles/.rvm/rubies/ruby-2.2.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/dmoles/.rvm/gems/ruby-2.2.1
- /Users/dmoles/.rvm/gems/ruby-2.2.1#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/dmoles/.rvm/gems/ruby-2.2.1/bin
- /Users/dmoles/.rvm/gems/ruby-2.2.1#global/bin
- /Users/dmoles/.rvm/rubies/ruby-2.2.1/bin
- /Users/dmoles/.rvm/bin
- /Users/dmoles/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/git/bin
I can build/install the gem fine with
gem build my-engine.gemspec
gem install my-engine-0.0.1.gem
after which rails -v starts working.* It doesn't seem like this should be necessary, though, and it makes me worry that Rails may be using the built/installed version of the code instead of the live source. What am I doing wrong?
* That is, it runs, even though it complains "Bundler is using a binstub that was created for a different gem". Possibly because it doesn't like the fact that the gem is named my-engine but the ENGINE_PATH has my/engine?
It doesn't make sense to call rails -v within the engine root since an engine is a gem after all that need to be loaded in a rails application, unless you have it structured like a normal rails app instead of an engine gem.
So basically, when you run rails -v, it will try to load your engine as a gem not as a normal rails application thus it will complain if its not installed in your environment.
It looks like somehow the local gem setup on this machine was corrupted -- even if I created a brand-new unrelated engine, it still complained about not being able to find my-engine. rm -r ~/.rvm/gems/ruby-2.2.1* / gem install rails fixed the problem (though at the price of having to reinstall a bunch of gems).

rails 4 deployment - rake stderr: config.eager_load is set to nil .. incorrect error message

during a project staging deployment w Capistrano, with a common db access error to be solved, I noticed the rake stderr line :
rake stderr: config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly..
however , my config/environments/*rb files are correctly set as required..
why this message ? what did I missed ?
my config/environments/development.rb
config.eager_load = false
my config/environments/production.rb
config.eager_load = true
my config/environments/test.rb
config.eager_load = false
here is the extract from the console log
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
* development - set it to false
* test - set it to false (unless you use a tool that preloads your test environment)
* production - set it to true
rake aborted!
Mysql2::Error: Access denied for user 'root'#'localhost' (using password: NO)
I had a similar issue when deploying with
cap staging deploy
The problem was that capistrano was looking for the database myapp_staging, while I needed myapp_production.
I fixed it by adding
set :stage, "production"
in config/deploy/staging.rb.
(Answered in the comments. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
#amoebe wrote:
I think the main problem here is wrong MySQL credentials.
The OP wrote:
you're right, I had to manage my production/staging deployment credentials via a capistrano task ( setup:upload_yml) to upload the secrets.yml and database.yml into my remote server.... running fine now...

Spree with Payupaisa Gateway

I want to add Payupaisa gateway for my shopping cart site. I use spree. I used gem
gem 'spree_payupaisa', :github => "meetdestiny/spree_payupaisa_express", :branch => "2-1-stable"
https://github.com/meetdestiny/spree_payupaisa_express
but it give error while I am updating bundle
Git error: command `git rev-parse 2-1-stable` in directory
/home/tps/.rvm/gems/ruby-2.0.0-p247#demo/cache/bundler/git/spree_payupaisa_express-6aebc199a8cbc824377ffe9416c892e73cc3271e has failed.
Thank in Advance.
The instructions on that repository are incorrect. That git repository doesn't have a 2-1-stable branch. Try the following in your Gemfile:
gem 'spree_payupaisa', :github => "meetdestiny/spree_payupaisa_express"
Which should currently work with Spree 2.1.
You should file an issue/pull request on the repository to correct the instructions.