-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The deploy doesn't create node_modules and raises Sprockets::FileNotFound (after upgrading to rails 7) #259
Comments
I found a solution! I share it here in case anyone has the same issue. Here's the code that I use: namespace :yarn do
task :install do
on release_roles(fetch(:assets_roles)) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, "yarn:install"
end
end
end
end
end
after 'bundler:install', 'yarn:install' Probably this task should be added directly to this gem. The issue was introduced by this change in the Rails repository: rails/rails#43641 |
The code in https://github.com/rails/webpacker/blob/master/docs/deployment.md worked for me. before "deploy:assets:precompile", "deploy:yarn_install"
namespace :deploy do
desc "Run rake yarn install"
task :yarn_install do
on roles(:web) do
within release_path do
execute("cd #{release_path} && yarn install --silent --no-progress --no-audit --no-optional")
end
end
end
end |
Is this a temporary solution? |
Also ran into this issue. Solved it using this solution. |
Steps to reproduce
After upgrading an application from Rails 6.1 to Rails 7.0 the Capistrano deployment fails.
The deployment has always worked (for years) and the application still works fine in development / test environments.
This is the error when running
cap production deploy
:After some investigation on the server I see that:
/home/myapp/www/myapp/releases/20220928123230/
is present/home/myapp/www/myapp/releases/20220928123230/node_modules
is not present (and this is where the fileemojionearea/dist/emojionearea
should be found)This probably means that the problem is not Sprockets (which is looking in the right path) but the fact that
node_modules
is not generated during the deploy. So, why the commandyarn install
is not executed during the deploy? Everything used to work before the upgrade to Rails 7.Expected behavior
The task
deploy:assets:precompile
should first download the Yarn modules to thenode_modules
folder on the server, then runrake assets:precompile
.Actual behavior
When you deploy,
assets:precompile
raises an exceptionSprockets::FileNotFound
.System configuration
Rails 7.0.4
capistrano 3.17.1
capistrano-rails 1.6.2
The text was updated successfully, but these errors were encountered: