Reputation: 5250
I don't have any assets folder inside my application's public(public/assets) directory. When I am trying to deploy with capistrano v3. A new folder called public/assets is created in my remote machine. I am also getting the following error because it searches a file called manifest.yml under public/assets(public/assets/manifest*). Is it necessary?? What is the purpose of this???
//getting the following error while deploying
DEBUG [014a40e4] Running /usr/bin/env [ -L /home/ec2-user/capistrano-3/my_app/releases/20140117124107/public/assets ] on 50.13.220.55
DEBUG [014a40e4] Command: [ -L /home/ec2-user/capistrano-3/my_app/releases/20140117124107/public/assets ]
DEBUG [014a40e4] Finished in 0.602 seconds with exit status 1 (failed).
DEBUG [9c5901ab] Running /usr/bin/env [ -d /home/ec2-user/capistrano-3/my_app/releases/20140117124107/public/assets ] on 50.13.220.55
DEBUG [9c5901ab] Command: [ -d /home/ec2-user/capistrano-3/my_app/releases/20140117124107/public/assets ]
DEBUG [9c5901ab] Finished in 0.639 seconds with exit status 1 (failed).
//// this error is at the end of the trace
** Invoke deploy:assets:backup_manifest (first_time)
** Execute deploy:assets:backup_manifest
DEBUG [a08f4c02] cp:
DEBUG [a08f4c02] cannot stat `/home/ec2-user/capistrano-3/my_app/releases/20140117064709/public/assets/manifest*'
DEBUG [a08f4c02] : No such file or directory
DEBUG [a08f4c02]
cap aborted!
cp stdout: Nothing written
cp stderr: Nothing written
Tasks: TOP => deploy:assets:backup_manifest
The deploy has failed with an error: #<SSHKit::Command::Failed: cp stdout: Nothing written
cp stderr: Nothing written
>
** Invoke deploy:failed (first_time)
** Execute deploy:failed
Upvotes: 2
Views: 2154
Reputation: 16002
By looks of it, you're probably using 3.1 or above version of rails in your application.
Basically, from the guide:
The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB.
Here is everything you need to know: http://guides.rubyonrails.org/asset_pipeline.html
As mentioned in guide, you can disable it by putting/modifying the following code in config/application.rb file:
config.assets.enabled = false
If you continue to use the asset pipeline then you can precompile your assets using this command:
rake assets:precompile
# or
rake assets:precompile:all
About the menifest.yml(from the guide itself):
The rake task also generates a manifest.yml that contains a list with all your assets and their respective fingerprints. This is used by the Rails helper methods to avoid handing the mapping requests back to Sprockets. A typical manifest file looks like:
---
rails.png: rails-bd9ad5a560b5a3a7be0808c5cd76a798.png
jquery-ui.min.js: jquery-ui-7e33882a28fc84ad0e0e47e46cbf901c.min.js
jquery.min.js: jquery-8a50feed8d29566738ad005e19fe1c2d.min.js
application.js: application-3fdab497b8fb70d20cfc5495239dfc29.js
application.css: application-8af74128f904600e41a6e39241464e03.css
So, when you run the rake task. It will generate the menifest.yml file which has entries of your assets, including the md5 hash digest, which is used for caching your assets on the client level. Every time you'll run the rake task, you'll get a new hash for your assets. Which validates/invalidates your assets when browser receives the response from server.
I encourage you to use assets pipeline as it will also gain you the ability to use CDN in a much nicer/easy way. However, at the end of the day it's your choice.
UPDATE:
For deploying in capistrano 3(since capistrano 3 has a lot of DSL changes) comes along with: require 'capistrano/deploy'
inside Capfile. So, you don't have to write your own precompile_assets task for your deployment.
Have a look at this answer: https://stackoverflow.com/a/15690628/645886, and this: http://blog.blenderbox.com/2013/11/06/precompiling-assets-with-capistrano-3-0-1/. I hope this helps.
Upvotes: 3
Reputation: 10035
This is the rails default functionality of Asset Pipeline. Read this for a better understanding. Asset Pipleine
The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB.
When you run the rails app in production environment, the media content present in app/assets is compiled and multiple files are concatenated into one for faster loading of assets.
You can check config/application.rb file.config.assets.enabled = true
This enables the asset pipelining.
When the asset precompilation takes place they are placed into public/assets folder and the entry is updated in manifest.yml file.
Rails app will by default search the assets in public/assets folder. The assets are not compiled again if no change has been done.
You can either compile assets using: rake assets:precompile
or when you restart the server it get compiled automatically. There has to be a js compiler present like node.js or rubyracer to compile js.
In case you want to avoid the compilation, disable it from application.rb and provide the path to your assets for production environment. In development mode the assets are served from app/assets. You can also try to run rake assets:precompile
and check if the assets folder under public is created.
Upvotes: 1