Вопрос

When running cap deploy, I get the following error when it tries to compile the assets:

*** [err :: 205.186.157.163] /usr/local/ruby-enterprise/bin/ruby /usr/local/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: 205.186.157.163] [DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.spree/order" is no longer supported
*** [err :: 205.186.157.163] [FATAL] failed to allocate memory
*** [err :: 205.186.157.163] rake aborted!

I watch the memory reach max using top every time. I did increase the memory allocation of the MediaTemple (ve) box to 1GB, with no success.

Context: Spree 1.0.3, rails 3.1, MediaTemple (ve) server with 1GB memory.

Any hints?

Это было полезно?

Решение

I actually got my problem fixed by following Ryan Bigg's suggestion here: https://github.com/spree/spree/issues/1183#issuecomment-5493863

Turns out sass-rails needed to be upgraded to branch 3-1-stable, and then everything ran perfectly.

Другие советы

I think this is a known issue with Rails 3.1, supposedly fixed in Rails 3.2. Also seeing another mention here. I ran into the same problem with a fresh install of Rails 3.1 and Spree 1.0 and no other dependencies.

Here's how I worked around it:

In the Capfile, comment this out:

load 'deploy/assets'

In my deploy.rb file, I copied what is provided in deploy/assets with the spree-rails gem but added the precompile_quick task. This compiles the CSS and JS but it looks like it might not actually be compressing the CSS and JS.

before 'deploy:finalize_update', 'deploy:assets:symlink'
after 'deploy:update_code', 'deploy:assets:precompile_quick'

namespace :deploy do
  namespace :assets do
    desc <<-DESC
      [internal] This task will set up a symlink to the shared directory \
      for the assets directory. Assets are shared across deploys to avoid \
      mid-deploy mismatches between old application html asking for assets \
      and getting a 404 file not found error. The assets cache is shared \
      for efficiency. If you cutomize the assets path prefix, override the \
      :assets_prefix variable to match.
    DESC
    task :symlink, :roles => assets_role, :except => { :no_release => true } do
      run <<-CMD
        rm -rf #{latest_release}/public/#{assets_prefix} &&
        mkdir -p #{latest_release}/public &&
        mkdir -p #{shared_path}/assets &&
        ln -s #{shared_path}/assets #{latest_release}/public/#{assets_prefix}
      CMD
    end

    desc <<-DESC
      Run the asset precompilation rake task. You can specify the full path \
      to the rake executable by setting the rake variable. You can also \
      specify additional environment variables to pass to rake via the \
      asset_env variable. The defaults are:

        set :rake,      "rake"
        set :rails_env, "production"
        set :asset_env, "RAILS_GROUPS=assets"
    DESC
    task :precompile_quick, :roles => assets_role, :except => { :no_release => true } do
      run "cd #{current_path} ; RAILS_ENV=#{rails_env} bundle exec rake assets:precompile:primary"
      run "cd #{current_path} ; RAILS_ENV=#{rails_env} bundle exec rake assets:precompile:nondigest"
    end

    desc <<-DESC
      Run the asset clean rake task. Use with caution, this will delete \
      all of your compiled assets. You can specify the full path \
      to the rake executable by setting the rake variable. You can also \
      specify additional environment variables to pass to rake via the \
      asset_env variable. The defaults are:

        set :rake,      "rake"
        set :rails_env, "production"
        set :asset_env, "RAILS_GROUPS=assets"
    DESC
    task :clean, :roles => assets_role, :except => { :no_release => true } do
      run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:clean"
    end
  end
end
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top