Posted almost 2 years ago. Visible to the public.

Capistrano 3 has slightly changed its symlink implementation

In Capistrano 2, directories in shared_children used to be symlinked to the shared directory during the finalize_update task.

# <capistrano>/lib/capistrano/recipes/deploy.rb _cset :shared_children, %w(public/system log tmp/pids) # ... task :finalize_update, :except => { :no_release => true } do # ... do |d| run "ln -s #{shared_path}/#{d.split('/').last} #{latest_release}/#{d}" # <-- symlinks only the last segment here end # ... end

This would symlink current/public/system to shared/system.

Capistrano 3 (which is almost a complete rewrite of the project) now properly expands paths to symlink. current/public/system is now symlinked to shared/public/system.

# <your project>/config/deploy.rb set :linked_dirs, %w(log public/system) # <capistrano>/lib/capistrano/tasks/deploy.rake desc 'Symlink linked directories' task :linked_dirs do # ... fetch(:linked_dirs).each do |dir| target = release_path.join(dir) # <-- symlinks the whole path source = shared_path.join(dir) # ... execute :ln, '-s', source, target end end

This may bite you when you were backing up the shared/system directory. After upgrading to Capistrano 3, you will need to back up the shared/public/system directory instead. For our own projects we already do so.

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Author of this card:

Dominik Schöler
Last edit:
over 1 year ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandropedia