capistrano fails on assets:precompile within cap deploy:cold - capistrano

I am doing a cap deploy:cold
with the following config/deploy.rb
1 require 'bundler/capistrano'
2
3 set :application, "massiveapp"
4
5 set :scm, :git
6
7 set :repository, "git://github.com/deployingrails/massiveapp.git"
8
9 server "localhost", :web, :app, :db, :primary => true
10
11 ssh_options[:port] = 2222
12 ssh_options[:keys] = "~/.vagrant.d/insecure_private_key"
13
14 set :user, "vagrant"
15 set :group, "vagrant"
16 set :deploy_to, "/var/massiveapp"
17 set :use_sudo, false
18
19 set :deploy_via, :copy
20 set :copy_strategy, :export
21
22 namespace :deploy do
23 task :start do ; end
24 task :stop do ; end
25 desc "Restart the application"
26 task :restart, :roles => :app, :except => { :no_release => true } do
27 run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
28 end
29 desc "Copy the database.yml file into the latest release"
30 task :copy_in_database_yml do
31 run "cp #{shared_path}/config/database.yml #{latest_release}/config/"
32 end
33 end
34 #before "deploy:copy_in_database_yml"
35 before "deploy:assets:precompile", "deploy:copy_in_database_yml"
It all goes fine up to the following at which point it fails.
* executing "cd /var/massiveapp/releases/20120808053801 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["localhost"]
[localhost] executing command
*** [err :: localhost] rake aborted!
*** [err :: localhost] (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
*** [err :: localhost]
*** [err :: localhost] Tasks: TOP => environment
*** [err :: localhost] (See full trace by running task with --trace)
command finished in 1196ms
*** [deploy:update_code] rolling back
* executing "rm -rf /var/massiveapp/releases/20120808053801; true"
servers: ["localhost"]
[localhost] executing command
command finished in 39ms
I am just learning capistrano and just don't know how to debug this to solve it.
Any help would be much appreciated.
rails 3.2.7 ruby 1.9.3 capistrano 2.12

Problem was caused by a tab character in the database.yml file.

The database.yml file is on the VM located at /var/massiveapp/shared/configs/database.yml.

Related

Get compile error on Lineage 16.0 when brunch bacon

I am building customer ROM for my OnePluse 1 phone based on lineage 16.0. After making some changes and brunch bacon, i got below error:
ju#suz-ubt-01l:~/android/lineage$ brunch bacon
...
...
...
build/target/product/core.mk was modified, regenerating...
[625/1039] including system/sepolicy/Android.mk ...
system/sepolicy/Android.mk:88: warning: Be careful when using the SELINUX_IGNORE_NEVERALLOWS flag. It does not work in user builds and using it will not stop you from failing CTS.
[1039/1039] including vendor/qcom/opensource/dataservices/Android.mk ...
build/make/core/Makefile:28: warning: overriding commands for target `/home/ju/android/lineage/out/target/product/bacon/system/vendor/lib/hw/android.hardware.nfc#1.0-impl.so'
build/make/core/base_rules.mk:412: warning: ignoring old commands for target `/home/ju/android/lineage/out/target/product/bacon/system/vendor/lib/hw/android.hardware.nfc#1.0-impl.so'
[ 86% 94/109] Building Kernel Config
make: Entering directory '/home/ju/android/lineage/kernel/oppo/msm8974'
GEN /home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ/Makefile
#
# configuration written to .config
#
make: Leaving directory '/home/ju/android/lineage/kernel/oppo/msm8974'
make: Entering directory '/home/ju/android/lineage/kernel/oppo/msm8974'
GEN /home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ/Makefile
scripts/kconfig/conf --savedefconfig=defconfig Kconfig
make: Leaving directory '/home/ju/android/lineage/kernel/oppo/msm8974'
[ 87% 95/109] Building Kernel
FAILED: TARGET_KERNEL_BINARIES
/bin/bash -c "(make -j2 -j\$(nproc) CFLAGS_MODULE=\"-fno-pic\" -C kernel/oppo/msm8974 O=/home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ ARCH=arm CROSS_COMPILE=\"/usr/bin/ccache arm-linux-androidkernel-\" zImage ) && (if grep -q '^CONFIG_OF=y' /home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ/.config; then echo \"Building DTBs\";make -j2 -j\$(nproc) CFLAGS_MODULE=\"-fno-pic\" -C kernel/oppo/msm8974 O=/home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ ARCH=arm CROSS_COMPILE=\"/usr/bin/ccache arm-linux-androidkernel-\" dtbs; fi ) && (if grep -q '=m' /home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ/.config; then echo \"Building Kernel Modules\"; make -j2 -j\$(nproc) CFLAGS_MODULE=\"-fno-pic\" -C kernel/oppo/msm8974 O=/home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ ARCH=arm CROSS_COMPILE=\"/usr/bin/ccache arm-linux-androidkernel-\" modules; fi )"
make: Entering directory '/home/ju/android/lineage/kernel/oppo/msm8974'
File "/home/ju/android/lineage/kernel/oppo/msm8974/scripts/gcc-wrapper.py", line 59
print "error, forbidden warning:", m.group(2)
^
SyntaxError: invalid syntax
GEN /home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ/Makefile
scripts/kconfig/conf --silentoldconfig Kconfig
File "/home/ju/android/lineage/kernel/oppo/msm8974/scripts/gcc-wrapper.py", line 59
print "error, forbidden warning:", m.group(2)
^
SyntaxError: invalid syntax
GEN /home/ju/android/lineage/out/target/product/bacon/obj/KERNEL_OBJ/Makefile
CHK include/linux/version.h
CC scripts/mod/empty.o
File "/home/ju/android/lineage/kernel/oppo/msm8974/scripts/gcc-wrapper.py", line 59
print "error, forbidden warning:", m.group(2)
^
SyntaxError: invalid syntax
/home/ju/android/lineage/kernel/oppo/msm8974/scripts/Makefile.build:307: recipe for target 'scripts/mod/empty.o' failed
make[3]: *** [scripts/mod/empty.o] Error 1
/home/ju/android/lineage/kernel/oppo/msm8974/scripts/Makefile.build:443: recipe for target 'scripts/mod' failed
make[2]: *** [scripts/mod] Error 2
/home/ju/android/lineage/kernel/oppo/msm8974/Makefile:510: recipe for target 'scripts' failed
make[1]: *** [scripts] Error 2
make[1]: *** Waiting for unfinished jobs....
Makefile:130: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
make: Leaving directory '/home/ju/android/lineage/kernel/oppo/msm8974'
ninja: build stopped: subcommand failed.
10:45:43 ninja failed with: exit status 1
#### failed to build some targets (01:13 (mm:ss)) ####
My environment info as below:
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=9
LINEAGE_VERSION=16.0-20200110-UNOFFICIAL-bacon
TARGET_PRODUCT=lineage_bacon
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=krait
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.0.0-37-generic-x86_64-Ubuntu-18.04.3-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=PQ3A.190801.002
OUT_DIR=/home/ju/android/lineage/out
PRODUCT_SOONG_NAMESPACES= hardware/qcom/audio-caf/msm8974 hardware/qcom/display-caf/msm8974
hardware/qcom/media-caf/msm8974
My python version is "Python 3.6.8 :: Anaconda, Inc."
Andy help should be appreciated, Thank you very much.
Create Conda environment with python version 2.7

Capistrano error on rake assets:precompile:all but still working (using RVM)

I've made a new Rails 3.2 application. When i deploy it with Capistrano, I get an error when compiling assets. But the assets ARE compiled, and the application deployed as it should.
On the server I've installed RVM systemwide and then created:
User: skolemapicture (added to group rvm)
Deploy folder: /home/skolemapicture/site
.rvmrc in /home/skolemapicture/site/.rvmrc
My deploy.rb config looks like this (omitted lines that have nothing to do with the problem)
set :application, "skolemapicture"
set :deploy_to , "/home/skolemapicture/site"
set :user , "skolemapicture"
set :use_sudo , false
ssh_options[:forward_agent] = true
require "bundler/capistrano"
require "rvm/capistrano"
set(:ruby_version) { '1.9.3' }
set(:rvm_ruby_string) { "#{ruby_version}##{application}" }
set(:rvm_path) { "/usr/local/rvm" }
set(:rvm_type) { :system }
namespace :deploy do
task :precompile, :role => :app do
run "cd #{release_path}/ && bundle exec rake assets:precompile"
end
end
after "deploy:finalize_update", "deploy:precompile"
The error i get at "cap deploy" is:
* 2013-02-13 10:36:21 executing `deploy:precompile'
* executing "cd /home/skolemapicture/site/releases/20130213093619/ && bundle exec rake assets:precompile"
servers: ["web01.mapicture.com"]
[web01.mapicture.com] executing command
*** [err :: web01.mapicture.com] /usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby /home/skolemapicture/site/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: web01.mapicture.com]
But the assets ARE compiled. So why this error?
/ Carsten
It is probably actually precompiling the assets successfully with your custom deploy:precompile task.
It is failing on the capistrano default assets:precompile task.
You will notice that the failed command is
/usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby /home/skolemapicture/site/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
not your custom precompile task:
cd #{release_path}/ && bundle exec rake assets:precompile
Try removing your deploy:precompile task and adding
load 'deploy/assets'
to your Capfile if it is not already there.
If that doesn't fix it can you post your entire Capfile and deploy.rb?

correct way to create symlink in deploy.rb

I have an error when i deploy an application:
[neon.locum.ru] executing command
*** [err :: neon.locum.ru] find: `/home/hosting_grandinvest/projects/demo/releases/20130116145843/public/images /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/stylesheets /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/javascripts': Нет такого файла или каталога
command finished in 91ms
triggering after callbacks for `deploy:update_code'
* 2013-01-16 16:58:45 executing `make_images_link'
* executing "ln -s /home/hosting_grandinvest/projects/demo/shared/public/images /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/images"
As you see it's because first it tries to find /public/images dir. and only then creates a symlink for that directory.
beggining of my deploy.rb
require 'bundler/capistrano'
after "deploy:update_code", :make_images_link
task :make_images_link, roles => :app do
images_dir = "#{shared_path}/public/images"
run "ln -s #{images_dir} #{release_path}/public/images"
end
the deploy finishes
Gem.source_index called from /home/hosting_grandinvest/projects/demo/shared/gems/ruby/1.8/gems/rails-2.3.15/lib/rails/gem_dependency.rb:21.
master process ready
worker=0 ready
reaped #<Process::Status: pid=18656,exited(0)> worker=0
master complete
in public/images dir are located some files used by css ( background: url(/images/front/logo.gif) no-repeat 0 0;) and they are Not displayed !but when i try to access these files directly
(http://hosting.net/images/front/logo.gif) i can see them!
Any suggestions on how to solve this error and make capistrano work?
UPDATE 1
I've included public/images/front in repo and after code deployment swap empty folder with a link
after "deploy:update_code", :make_images_link
task :make_images_link, roles => :app do
images_dir = "#{shared_path}/public/images"
realease_images = "#{release_path}/public/images"
run "rm -rf #{realease_images}"
run "ln -s #{images_dir} #{realease_images}"
end
When i deploy error still exists, but images appeared!
In the end i've included 'public'images' dir in my repository.
and as step 2 i run a callback that i've specified in update 1.

Capifony and directory owners

When I cap deploy my Symfony2 project, then log into my server I see that the the dev (app_dev.php) runs ok but the prod version (app.php) does not.
The error is
[Tue Jan 03 14:31:48 2012] [error] [client xxx.xxx.xxx.xxx] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to write cache file "/var/www/example/prod/releases/20120103202539/app/cache/prod/classes.php".' in /var/www/example/prod/releases/20120103202539/app/bootstrap.php.cache:1079\nStack trace:\n#0 /var/www/example/prod/releases/20120103202539/app/bootstrap.php.cache(1017): Symfony\\Component\\ClassLoader\\ClassCollectionLoader::writeCacheFile('/var/www/example/p...', '<?php ????name...')\n#1 /var/www/example/prod/releases/20120103202539/app/bootstrap.php.cache(682): Symfony\\Component\\ClassLoader\\ClassCollectionLoader::load(Array, '/var/www/example/p...', 'classes', false, false, '.php')\n#2 /var/www/example/prod/releases/20120103202539/web/app.php(10): Symfony\\Component\\HttpKernel\\Kernel->loadClassCache()\n#3 {main}\n thrown in /var/www/example/prod/releases/20120103202539/app/bootstrap.php.cache on line 1079
Looking at the recently deployed cache directory I see:
drwxrwxrwx 4 root root 4096 Jan 3 14:28 .
drwxrwxr-x 5 root root 4096 Jan 3 14:28 ..
drwxr-xr-x 6 www-data www-data 4096 Jan 3 14:28 dev
drwxrwxr-x 7 root root 4096 Jan 3 14:28 prod
I can fix the issue with chown -R www-data.www-data prod/ but I wondered if I can stop this from happening in the first place? And why do the directories have different owners?
This happens because your web-server is running by user, who is not able to write to just created cache/prod directory.
There are two solutions, which I know and use. First, add extra commands to run after deployment to Capfile. Capfile will like this:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/bundles/*/*/recipes/*.rb'].each { |bundle| load(bundle) }
load Gem.find_files('symfony2.rb').last.to_s
after "deploy:finalize_update" do
run "sudo chown -R www-data:www-data #{latest_release}/#{cache_path}"
run "sudo chown -R www-data:www-data #{latest_release}/#{log_path}"
run "sudo chmod -R 777 #{latest_release}/#{cache_path}"
end
load 'app/config/deploy'
Second solution is more elegant. You specify correct user, who can write to cache in deploy.rb and make sure that you don't use sudo:
set :user, "anton"
set :use_sudo, false
In the last version of capifony, they've added the option to set writable directories.
Here's the official article which explains what I've written below : http://capifony.org/cookbook/set-permissions.html
You have to deploy using sudo (not a good practice, but it gets the job done)
set :use_sudo, false
# To prompt the sudo password
default_run_options[:pty] = true
and tell capifony which files to make cache and logs folder writable :
set :writable_dirs, ["app/cache", "app/logs"]
set :webserver_user, "www-data"
set :permission_method, :acl
(you have to install acl on your machine, or use :chwon instead of :acl)
EDIT :
I've just realized that this is not enough, the "set_permissions" task is not automatically called, so you have to explicitly run
cap deploy:set_permissions
Or add this line in your deploy.rb :
before "deploy:restart", "deploy:set_permissions"
I solved this problem by adding cache folder to shared folders.
set :shared_children, [app_path + "/cache", app_path + "/logs", web_path + "/uploads", "vendor"]
This way the directory is not recreated each time during deployment, so there is no problem with permissions.
Yes, don't need recreate cache every time after deploy, this solution is logical and pragmatical.
Second solution from Anton - is work if you cache folder permission true in develop environment

Capistrano cannot find SVN client

I have an SVN client locally and on the Solaris production server, and they are in my path, so when I type svn somethng the command is found (my PC and Solaris).
This is the error:
C:\dev\apps>cap deploy:migrations
* executing `deploy:migrations'
* executing `deploy:update_code'
executing locally: "svn info https://svn.domain.co.uk/svn/apps -rHEAD"
*** executable 'svn' not present or not in $PATH on the local system!
* executing "svn checkout -q -r6 https://svn.domain.co.uk/svn/apps /sites/r
ails-data/apps/releases/20100120114312 && (echo 6 > /sites/rails-data/apps/relea
ses/20100120114312/REVISION)"
servers: ["solaris001.ds.domain.com"]
Password:
[solaris001.ds.domain.com] executing command
** [solaris001.ds.domain.com :: err] ld.so.1: svn: fatal: libaprutil-1.so.
0: open failed: No such file or directory
** [solaris001.ds.domain.com :: err] Killed
command finished
failed: "sh -c 'svn checkout -q -r6 https://svn.domain.co.uk/svn/apps /sites/
rails-data/apps/releases/20100120114312 && (echo 6 > /sites/rails-data/apps/rele
ases/20100120114312/REVISION)'" on solaris001.ds.domain.com
In my PC and in Solaris I can successfully run the commands that Capistrano is unable it cannot find the library and the executable.
This is my recipe:
set :application, "apps"
set :user, 'me'
set :domain, "solaris001.ds.domain.com"
set :repository, "https://svn.domain.co.uk/svn/apps"
set :use_sudo, false
set :deploy_to, "/sites/rails-data/#{application}"
role :app, domain
role :web, domain
namespace :deploy do
task :start, :roles => :app do
run "touch #{current_release}/tmp/restart.txt"
end
task :stop, :roles => :app do
# Do nothing.
end
desc "Restart Application"
task :restart, :roles => :app do
run "touch #{current_release}/tmp/restart.txt"
end
end
The solution: http://riccardotacconi.blogspot.com/2010/01/rails-deployment-with-capistrano-and.html

Categories