Skip to content
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

rake failed when server and local use different rvm path #31

Open
xiaohui-zhangxh opened this issue Mar 27, 2019 · 4 comments
Open

rake failed when server and local use different rvm path #31

xiaohui-zhangxh opened this issue Mar 27, 2019 · 4 comments

Comments

@xiaohui-zhangxh
Copy link

On my server, it uses system-wide rvm, however on my mac it's user-wide. Gem capistrano-rvm will append rvm prefix to rake, then local assets precompile will get failed.

This is my solution:

namespace :load do
  task :defaults do
    before "deploy:assets:prepare", "remove_rvm_prefix"
    after "deploy:assets:prepare", "restore_rvm_prefix"
  end
end

task "remove_rvm_prefix" do
  i = SSHKit.config.command_map.prefix[:rake].index { |x| x =~ /rvm/ }
  $removed_rvm_prefix = [i, SSHKit.config.command_map.prefix[:rake].delete_at(i)] if i
end

task "restore_rvm_prefix" do
  if $removed_rvm_prefix
    SSHKit.config.command_map.prefix[:rake].insert(*$removed_rvm_prefix)
  end
end
@mlabarca
Copy link

Thanks @xiaohui-zhangxh this did the trick! Maybe this can be added to the readme?

@dncastilho
Copy link

Had the same issue. Applied your fix, now I have

LoadError: cannot load such file -- uglifier
/home/developer/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in require' /home/developer/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in block in require'
/home/developer/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in load_dependency' /home/developer/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in require'
/home/developer/.rvm/gems/ruby-2.6.3/gems/sprockets-3.7.2/lib/sprockets/autoload/uglifier.rb:1:in `

'

@JSRossiter
Copy link

xiaohui's solution was giving me an error about modifying load:defaults after it had run, so I changed it to the below and that worked for me

namespace :load do
  before "deploy:assets:prepare", "remove_rvm_prefix"
  after "deploy:assets:prepare", "restore_rvm_prefix"
end

@willianveiga
Copy link

Had the same issue. Applied your fix, now I have

LoadError: cannot load such file -- uglifier
/home/developer/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in require' /home/developer/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in block in require'
/home/developer/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in load_dependency' /home/developer/.rvm/gems/ruby-2.6.3/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in require'
/home/developer/.rvm/gems/ruby-2.6.3/gems/sprockets-3.7.2/lib/sprockets/autoload/uglifier.rb:1:in `

'

@dncastilho, move uglifier gem outside the assets group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants