Ask your Symfony questions! Pay money and get answers fast! (more info)

Capifony not installing bundles in remote server Symfony

  • SOLVED

I'm trying to deploy a Symfony2 project using Capifony. It's been very painful so far. I got to the point where I was able to deploy to the server, but the <strong>bundles </strong>I've installed don't make it to the server.

My deploy.rb file:

set :application, "myapplication"
set :domain, "mydomain.com"
set :deploy_to, "/home/myuser/myapplication"
set :scm, :git
set :repository, "/media/windows-share/symfony2_test"
set :deploy_via, :rsync_with_remote_cache

set :user, "myuser"

set :shared_files, ["app/config/parameters.ini"]
set :shared_children, ["logs", "web/uploads", "vendor"]
<strong>set :update_vendors, true</strong>
set :dump_assetic_assets, true

role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Rails migrations will run

set :use_sudo, false
set :keep_releases, 5


My Capfile:

load File.join(File.dirname(__FILE__), 'deploy.rb') if respond_to?(:namespace)
Dir[File.join(File.dirname(__FILE__),'vendor/plugins/*/recipes/*.rb')].each { |plugin| load(plugin) }
load File.join(File.dirname(__FILE__), 'app/config/deploy.rb')


This is the output I get after doing

command finished in 39958ms
* executing "rsync -a --delete /home/myuser/myapp/shared/cached-copy/ /home/myuser/myapp/releases/20111029080320/"
servers: ["example.com"]
Password:
[example.com] executing command
command finished
* executing `deploy:finalize_update'
* executing "chmod -R g+w /home/myuser/myapp/releases/20111029080320"
servers: ["example.com"]
[example.com] executing command
command finished
* executing "rm -rf /home/myuser/myapp/releases/20111029080320/log /home/myuser/myapp/releases/20111029080320/public/system /home/myuser/myapp/releases/20111029080320/tmp/pids &&\\\n mkdir -p /home/myuser/myapp/releases/20111029080320/public &&\\\n mkdir -p /home/myuser/myapp/releases/20111029080320/tmp &&\\\n ln -s /home/myuser/myapp/shared/log /home/myuser/myapp/releases/20111029080320/log &&\\\n ln -s /home/myuser/myapp/shared/system /home/myuser/myapp/releases/20111029080320/public/system &&\\\n ln -s /home/myuser/myapp/shared/pids /home/myuser/myapp/releases/20111029080320/tmp/pids"
servers: ["example.com"]
[example.com] executing command
command finished
* executing "find /home/myuser/myapp/releases/20111029080320/public/images /home/myuser/myapp/releases/20111029080320/public/stylesheets /home/myuser/myapp/releases/20111029080320/public/javascripts -exec touch -t 201110290803.43 {} ';'; true"
servers: ["example.com"]
[example.com] executing command
*** [err :: example.com] find:
*** [err :: example.com] /home/myuser/myapp/releases/20111029080320/public/images
*** [err :: example.com] : No such file or directory
*** [err :: example.com]
*** [err :: example.com] find:
*** [err :: example.com] /home/myuser/myapp/releases/20111029080320/public/stylesheets
*** [err :: example.com] : No such file or directory
*** [err :: example.com]
*** [err :: example.com] find:
*** [err :: example.com] /home/myuser/myapp/releases/20111029080320/public/javascripts
*** [err :: example.com] : No such file or directory
*** [err :: example.com]
command finished
* executing `deploy:symlink'
* executing "rm -f /home/myuser/myapp/current && ln -s /home/myuser/myapp/releases/20111029080320 /home/myuser/myapp/current"
servers: ["example.com"]
[example.com] executing command
command finished
** transaction: commit
* executing `deploy:restart'
* executing "/home/myuser/myapp/current/script/process/reaper"
servers: ["example.com"]
[example.com] executing command
*** [err :: example.com] sh: /home/myuser/myapp/current/script/process/reaper: No such file or directory
command finished
failed: "sh -c \"/home/myuser/myapp/current/script/process/reaper\"" on example.com


Note: I have created a "script/process/reaper" folder in my local installation and added it to git. Final thing, the vendor lib is in git ignore.

Answers (2)

2011-10-29

Luis Cordova answers:

this is easy

please create the following folders
/home/myuser/myapp/releases/20111029080320/public/images
/home/myuser/myapp/releases/20111029080320/public/stylesheets
/home/myuser/myapp/releases/20111029080320/public/javascripts

even if they have empty content, place a readme.txt inside each folder and do git add . && git commit -a and commit the 3 files inside the folders above.

Then try again, now you will not have those errors, this is a known bug in capifony.

I know there will be more errors down the road but this will get rid of these errors.

I have deployed with capifony several months now so you are in good hands.

remember also to push to your repo after you have committed, so it will work well.

very well known bug https://github.com/everzet/capifony/issues/45

also @ http://www.craftitonline.com I have at least 3 blog post on capifony and one with a full configuration file and experiences shared.


fxsymfony comments:

Hi Luis, thanks for your help. I created those three folders with a readme file inside, do I also need to place a readme file inside script/process/reaper?

The bundles are still not there..

This is my output not:

* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
executing locally: "git ls-remote /media/windows-share/symfony2_test HEAD"
executing locally: cd /media/windows-share/symfony2_test/.rsync_cache && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 97e72586dd662a33e8dcba52173b4a9af97fff92 && git clean -q -d -x -f
command finished in 145578ms
executing locally: rsync -az --delete --rsh='ssh -p 22' /media/windows-share/symfony2_test/.rsync_cache/ [email protected]:/home/myuser/myapp/shared/cached-copy/
[email protected]'s password:
command finished in 95390ms
* executing "rsync -a --delete /home/myuser/myapp/shared/cached-copy/ /home/myuser/myapp/releases/20111029231442/"
servers: ["example.com"]
Password:
[example.com] executing command
command finished
* executing `deploy:finalize_update'
* executing "chmod -R g+w /home/myuser/myapp/releases/20111029231442"
servers: ["example.com"]
[example.com] executing command
command finished
* executing "rm -rf /home/myuser/myapp/releases/20111029231442/log /home/myuser/myapp/releases/20111029231442/public/system /home/myuser/myapp/releases/20111029231442/tmp/pids &&\\\n mkdir -p /home/myuser/myapp/releases/20111029231442/public &&\\\n mkdir -p /home/myuser/myapp/releases/20111029231442/tmp &&\\\n ln -s /home/myuser/myapp/shared/log /home/myuser/myapp/releases/20111029231442/log &&\\\n ln -s /home/myuser/myapp/shared/system /home/myuser/myapp/releases/20111029231442/public/system &&\\\n ln -s /home/myuser/myapp/shared/pids /home/myuser/myapp/releases/20111029231442/tmp/pids"
servers: ["example.com"]
[example.com] executing command
command finished
* executing "find /home/myuser/myapp/releases/20111029231442/public/images /home/myuser/myapp/releases/20111029231442/public/stylesheets /home/myuser/myapp/releases/20111029231442/public/javascripts -exec touch -t 201110292315.01 {} ';'; true"
servers: ["example.com"]
[example.com] executing command
command finished
* executing `deploy:symlink'
* executing "rm -f /home/myuser/myapp/current && ln -s /home/myuser/myapp/releases/20111029231442 /home/myuser/myapp/current"
servers: ["example.com"]
[example.com] executing command
command finished
** transaction: commit
* executing `deploy:restart'
* executing "/home/myuser/myapp/current/script/process/reaper"
servers: ["example.com"]
[example.com] executing command
*** [err :: example.com] sh: /home/myuser/myapp/current/script/process/reaper: No such file or directory
command finished
failed: "sh -c \"/home/myuser/myapp/current/script/process/reaper\"" on example.com


Luis Cordova comments:

right see?

now those things passed

now it is a different errors

so here



** transaction: commit

* executing `deploy:restart'

* executing "/home/myuser/myapp/current/script/process/reaper"

servers: ["example.com"]

[example.com] executing command

*** [err :: example.com] sh: /home/myuser/myapp/current/script/process/reaper: No such file or directory

command finished

failed: "sh -c \"/home/myuser/myapp/current/script/process/reaper\"" on example.com


fxsymfony comments:

I also created an empty readme file in /script/process/reaper but the error is the same as above....


fxsymfony comments:

I thought reaper had to be a folder, but it had to be a file, so created an empty file called reaper, now I don't get any errors, but still no bundles.

I think it's related to Jakub's answer. I don't have a "symfony2.rb" file anywhere so I get an error when running that code. Instead, I'm running the capistrano version in the Capfile:

load File.join(File.dirname(__FILE__), 'deploy.rb') if respond_to?(:namespace)
Dir[File.join(File.dirname(__FILE__),'vendor/bundles/*/*/recipes/*.rb')].each { |bundle| load(bundle) }
load File.join(File.dirname(__FILE__), 'app/config/deploy.rb')


Luis Cordova comments:

right now it is related to what Jakub was saying.

So you first must decide whether you are using capistrano or capifony, if capifony then follow instructions according to capifony.org if not then go for capistrano instructions. But do not mix both please.


fxsymfony comments:

I followed Jakub advise, now it is using capifony properly.

Thanks for the help to get there.

I'm getting a different error now on the server when doing php bin/vendors install -- reinstall, but it's out of the scope of this question.

Warning: Wrong parameter count for parse_ini_file() in /home/myuser/myapp/releases/20111030001344/bin/vendors on line 69

Warning: Invalid argument supplied for foreach() in /home/myuser/myapp/releases/20111030001344/bin/vendors on line 73

Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/myuser/myapp/releases/20111030001344/vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php on line 35

Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/myuser/myapp/releases/20111030001344/app/console on line 14

Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/myuser/myapp/releases/20111030001344/app/console on line 14


Luis Cordova comments:

yes definitely you messed up on the config files, that is completely different, go to symfony2 ml now, thanks!, hope i get a chunk of the money or all :D, may $2 ... makes me think

2011-10-29

Jakub Zalas answers:

It looks like you didn't actually capify your project. It looks like you used capistrano instead of capifony.

Capfile created by capifony looks like this:

load 'deploy' if respond_to?(:namespace)
Dir['vendor/bundles/*/*/recipes/*.rb'].each { |bundle| load(bundle) }
load Gem.find_files('symfony2.rb').last.to_s
load 'app/config/deploy'


Yours looks like created by capistrano.

Start over again. Remember, to capify your project run:

capifony .

in your project directory.

More here: http://capifony.org/

If you need multistage deployment read my article on the subject: http://www.zalas.eu/multistage-deployment-of-symfony-applications-with-capifony


fxsymfony comments:

Hi Jakub, thanks for your response. I'm using that content in the file because with the default one it couldn't find the files, I had a Load Error..


fxsymfony comments:

This is what I get when using you suggested file.

[email protected]:/media/windows-share/symfony2_test$ cap deploy
/usr/lib/ruby/1.8/capistrano/configuration/loading.rb:183:in `find_file_in_load_path': no such file to load -- (LoadError)
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:171:in `load_from_file'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:89:in `load'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in `load'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in `each'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in `load'
from Capfile:5:in `load'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:172:in `load_from_file'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:89:in `load'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in `load'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in `each'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in `load'
from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in `load_recipes'
from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in `each'
from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in `load_recipes'
from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:30:in `execute!'
from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:14:in `execute'
from /usr/bin/cap:4


This is what I'm using now, but the bundles still don't get transferred to the server:

load File.join(File.dirname(__FILE__), 'deploy.rb') if respond_to?(:namespace)
Dir[File.join(File.dirname(__FILE__),'vendor/bundles/*/*/recipes/*.rb')].each { |bundle| load(bundle) }
load File.join(File.dirname(__FILE__), 'app/config/deploy.rb')