Capistrano 3 + Sprockets 3 + Rails 4.2.1 won't deploy?

后端 未结 3 1401
别那么骄傲
别那么骄傲 2021-02-05 13:59

I ran bundle update and updated sprockets to 3.0.0.

When I try to deploy via Capistrano 3 I get the following error:

INFO [e54a         


        
3条回答
  •  梦谈多话
    2021-02-05 14:04

    The problem is easy to fix, but I think that first we should address some of the other questions.

    sprockets is a ruby library that automates managing web front end assets (CSS, JS, images, etc).

    It is based on the idea of keeping your asset files logically organized in development, and to then chain and minify them before deploying to production. Sprockets makes this process automatic.

    Rails 3.1 (a long time ago, now) released a new feature called "Asset Pipeline", that automated the management of web assets. The Rails' Asset Pipeline was, and still is, powered by sprockets.

    Both sprockets and rails are actively maintained and developed libraries. New versions are released with new features and breaking changes.
    I believe that Rails does not use, by default, the latest version of sprockets. It is ok, we're talking about compiling CSS and JS here, not interacting with some external API; even an old version of sprockets can do the job.
    This means that updating sprockets is not a good idea. Each version of Rails declares a specific (min-max) version of sprockets, for good reason: it's the version that the current Asset Pipeline relies on. Updating it might break things.

    Then, let's move to the manifest file.
    By default, after precompiling the assets (resolving references, including some files into others, chaining and minifying them), the compiled assets are copied in RAILS_ROOT/public/assets. With them, Rails generates a manifest file that contains a list of all the precompiled assets. In your version of Rails it should be manifest.json, but it used to be manifest.yml.

    Now, the last piece of the puzzle is capistrano, which I imagine you know how to use.

    The line:

    cp: cannot stat ‘/var/www/testapp/releases/20150414002210/public/assets/manifest*’
    

    means that capistrano tried to find a manifest file in your RAILS_ROOT/public/assets directory. The wildcard is there because it might be either manifest.json or manifest.yml, depending on the version of Rails.
    Also, stat means that capistrano is trying to get some info from the file, probably to figure out how recent it is.

    The problem is that the file is not present.
    You should precompile the assets, then commit the generated files and try to deploy again.

提交回复
热议问题