I have been using Capistrano 3 to deploy a PHP app for several months and it works great. Recently, we decided to start using Sass for stylesheets and I am now trying to deploy these changes.
I am trying to write a task that runs after the rest of the deploy stuff is finished that converts a scss file to css using the Sass gem.
namespace :deploy do
after :finished, :assets do
on roles(:app), in: :sequence, wait: 5 do
within release_path do
# process sass files to css
execute "sass #{release_path}/styles/test.scss #{release_path}/styles/test.css"
end
end
end
end
I am using RVM on the server and have the sass gem installed in a specific gemset. There is also an .rvmrc file in the project root that loads the correct gemset when you cd into the 'current' directory that capistrano creates.
When I deploy, it fails on my new task saying that it cannot find sass.
stderr: bash: sass: command not found
I can log into the server as the same user that is used to deploy with Capistrano and cd into the 'current' directory and run the same command in the task (substituting the #{release_path} with actual path) and it works fine.
Things I have tried:
- rewriting the execute command with the following:
rvm use 2.1.5@deployer && sass #{release_path}/styles/test.scss #{release_path}/styles/test.css
writing a bash script accessible by the deployer user that loads the gemset then runs the sass command (works when I run the new script while logged into the sever in any directory, does not work when called from the capistrano task)
using the capistrano-rvm plugin (adding to Gemfile, requiring in Capfile) to set the RVM gemset - hoping that it would load the gemset before running any commands.
I have used Capistrano many times for deploying Rails apps and always use the asset plugin that handles precompiling and whatnot... This is the first project that I have used for deploying a PHP app and maybe the first time I have tried to manually run a capistrano task that uses a rubygem installed on the server with RVM.
Is it possible to run a task that depends on a specific gem/gemset... without using the default rails plugins?
Any help is appreciated.
Thanks, JD