<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lucas Freymund Ehresmann Osik</title>
    <description>The latest articles on DEV Community by Lucas Freymund Ehresmann Osik (@freymunddeveloper).</description>
    <link>https://dev.to/freymunddeveloper</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1201420%2F5eb995fc-b75b-40a5-9bc8-3976724a588b.jpeg</url>
      <title>DEV Community: Lucas Freymund Ehresmann Osik</title>
      <link>https://dev.to/freymunddeveloper</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/freymunddeveloper"/>
    <language>en</language>
    <item>
      <title>Asset precompile issue during Capistrano deployment process on legacy Rails code</title>
      <dc:creator>Lucas Freymund Ehresmann Osik</dc:creator>
      <pubDate>Sat, 04 Nov 2023 03:14:54 +0000</pubDate>
      <link>https://dev.to/freymunddeveloper/asset-precompile-issue-when-deploying-with-capistrano-to-legacy-rails-code-5d1f</link>
      <guid>https://dev.to/freymunddeveloper/asset-precompile-issue-when-deploying-with-capistrano-to-legacy-rails-code-5d1f</guid>
      <description>&lt;p&gt;Recently I was using Capistrano (version: 3.17.3) as a deployment tool for a Rails 5.2 application, along with other legacy content, such as JQuery. During the deployment process, the asset pre-compile step returned the error:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sprockets::FileNotFound: could not find file 'jquery/dist/jquery' with type 'application/javascript'&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Investigating the issue, I discovered that Capistrano is not installing my Node dependencies with Yarn (version: 3.6.3), within the production environment during deployment, possibly due to some incompatibility with the current version of Yarn I was using.&lt;/p&gt;

&lt;p&gt;I managed to solve the problem by placing a task in "config/deploy.rb" that forces "yarn install" to be executed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set :stage, :production
set :rails_env, 'production'

namespace :deploy do
    desc 'Install Node.js dependencies'
    task :install_node_dependencies do
        on roles(:app) do
            within release_path do
                execute :yarn, 'install --production' 
            end
        end
    end

    before 'deploy:assets:precompile', 'deploy:install_node_dependencies'
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>rails</category>
      <category>ruby</category>
      <category>deploy</category>
      <category>capistrano</category>
    </item>
  </channel>
</rss>
