Capistrano 3 + Sprockets 3 + Rails 4.2.1 won't deploy?
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.
Upgrade rails from 4.2 to 5.2 dependencies issue
First, as ThorTL67 noted in the comments, it is a good idea to update your Rails version incrementally, not in one big leap. That way, your dependency issues will be less complex.
Check what version of Bundler
you are using by running bundle version
. If that version is old, it might be that some dependencies are not correctly calculated, and it might help to update Bundler (gem update bundler
).
Then to the steps you can take to update from 4.2 to 'some higher version'. The list of errors that you got shows the conflicts between gem dependencies. You can try and tackle these conflicts one by one.
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
rails (~> 5.2) was resolved to 5.2.1.rc1, which depends on
activerecord (= 5.2.1.rc1)
schema_plus_views was resolved to 0.3.1, which depends on
activerecord (~> 4.2)
This error is pretty straightforward. It tells you that gem rails
needs activerecord
v5.2.1, but that gem schema_plus_views
needs activerecord
>= 4.2.0 but < 5.0 (see the RubyGems explanation of constraints). So how to resolve this? If you check the source page for schema_plus_views
, you see that there is no compatible version yet for activerecord
v5.2.1, and that it is not likely to be there soon: Any plan to update this gem to be compatible with rails 5.2?
So in this case, you have a few options. Leave it out of your Gemfile and remove the dependencies on this gem from your code; check for alternative gems that give you the needed functionality; help to update the gem to support rails 5.
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (~> 5.2)
gaffe was resolved to 1.2.0, which depends on
rails (>= 4.0.0)
rails_admin was resolved to 1.3.0, which depends on
rails (< 6, >= 4.0)
rails_admin_globalize_field was resolved to 0.4.0, which depends on
rails (>= 4.2)
sql-logging was resolved to 3.0.10, which depends on
rails (>= 4.0)
I'm actually not sure what the problem is here. These dependencies on the rails
gem do not seem to contradict each other, so I would try to find out what gem is the actual problem by commenting them out one by one and then trying the update again. This might give you more information.
Bundler could not find compatible versions for gem "rake":
In Gemfile:
rake (~> 11.2)
capistrano (~> 3.6) was resolved to 3.11.0, which depends on
rake (>= 10.0.0)
derailed_benchmarks was resolved to 1.3.2, which depends on
rake (< 13, > 10)
This also seems like it should not be a problem. I would try to change your rake dependency in your Gemfile from gem 'rake', '~> 11.2'
to gem 'rake'
and see what happens with the dependency messages.
Chances are that after all these steps, you will get different error messages. You have to tackle them one by one in the same manner. Unfortunately, there is no silver bullet, and updating Rails can be a tedious process, especially when your application depends on a lot of gems. You have to fix this, issue by issue, by removing your own dependencies on gems, helping gem communities with maintenance/updates, or (worst case) forking a gem and changing the code yourself to make it work again for your application. Good luck!
Related Topics
Rails 4 Update Nested Attributes
Consuming Non-Rest APIs in Rails with Activeresource
Add a Callback Function to a Ruby Array to Do Something When an Element Is Added
How to Do Named Capture in Ruby
Is It a Bad Idea to Reload Routes Dynamically in Rails
Rails Pass Params/Arguments to Activerecord Callback Function
Sunspot_Rails Gem - " Errno:: Econnrefused (Connection Refused - Connect (2)) "
Discriminate First and Last Element in Each
Map an Array Modifying Only Elements Matching a Certain Condition
Carrierwave File Upload with Different File Types
Simple Regex -- Replace Underscore with a Space
Paperclip: Upload from Url with Extension
What Does "No Binary Rubies Available" Mean
How to Resolve Deprecation Warnings for Openssl::Cipher::Cipher#Encrypt