我正在建立一个Ruby on Rails生产环境。我正在使用RVM的多用户安装。运行rake资产时:预编译我收到以下错误。其他rake任务似乎工作正常。
ruby@myserver:/sites/rails/necura_staging/shared/cached-copy$ bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby ruby /usr/local/rvm/gems/ruby-1.9.3-p448@global/bin/rake assets:precompile --trace assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby: No such file or directory -- ruby /usr/local/rvm/gems/ruby-1.9.3-p448@global/bin/rake assets:precompile --trace (LoadError)
rake aborted!
Command failed with status (1): [/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/...]
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/file_utils.rb:55:in `block in create_shell_runner'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/file_utils.rb:45:in `sh'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `sh'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/file_utils.rb:82:in `ruby'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/file_utils_ext.rb:37:in `ruby'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.11/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.11/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-3.2.11/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p448@global/bin/rake:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p448/bin/ruby_executable_hooks:14:in `<main>'
Tasks: TOP => assets:precompile
错误似乎表明找不到Ruby,但事实并非如此:
$ ls /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby
/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/rub
此外,我可以成功运行资产:使用rake through ruby进行预编译,如下所示。我从上面显示的错误中得到了这个想法。这很奇怪,因为这似乎是导致问题的原因。但手动运行它。
$ ruby /usr/local/rvm/gems/ruby-1.9.3-p448@global/bin/rake assets:precompile RAILS_ENV=staging
为什么会这样?这可能与我使用多用户或全局安装RVM的事实有关吗?
由于
答案 0 :(得分:4)
我遇到了同样的问题。我通过恢复到ruby-1.9.3-p392来修复它,此时我收到了关于可执行挂钩的错误,这引出了我这个问题。然后我跑了:
rvm ruby-1.9.3-p392@global do gem install executable-hooks
基于mpapis的答案(谢谢你!)现在一切似乎都在为我工作。
我原来的问题在这里:rake assets:precompile error message: No such file or directory -- ruby
答案 1 :(得分:2)
运行:
rvm ruby-1.9.3-p448@global do gem install executable-hooks