部署 Could not find multi_json-1.8.4 in any of the sources

autumnwolf · 2014年01月12日 · 最后由 Martin91 回复于 2014年01月13日 · 3257 次阅读

在服务器上运行 bundle install 和 gem install multi_son 都好用。

deploy.rb

task :staging do
      transaction do
        update_code
        migrate
      end
      restart
    end

...
task :migrate, :roles => :app, :only => {:primary => true} do
    #run "cd #{deploy_to} && bundle install"
    #production 下 用 production
    run "cd #{deploy_to} && RAILS_ENV=staging bundle exec rake assets:precompile"
    #run "cd #{deploy_to} && bundle exec rake db:auto:migrate"
    #run "rake assets:precompile"
  end
...
end

(1) 如果 run "cd #{deploy_to} && bundle install" 错误:

/usr/lib/ruby/1.9.1/rubygems/format.rb:38:in `from_file_by_path': Cannot load gem at [/usr/lib/ruby/gems/1.9.1/cache/multi_json-1.8.4.gem] in /home/yzhang/instigatestaging/instigateweb (Gem::Exception)

(2) 在服务器上,“bundle install”和“gem install multi_json”都没有错误

所以想问下 (1)和 (2) bundle install 不是一样的么?只是一个服务器直接运行一个本地运行,为什么会有错误呢。还有我的服务器上 rvm use 2.0.0 default,但是上面的错误貌似是 ruby 用了 1.9.1. 求解。

PS: mutli_json 1.8.4 需要在 ruby 1.9.3 以上。

前段时间用 ruby 2.1 也有同样的问题,忘记怎么解决的了…删掉 gemfile.lock 然后重新运行 bundle 试试

试试rm -rf /usr/lib/ruby/gems/1.9.1/cache/multi_json-1.8.4.gem?

@chareice #2 楼 @Martin91 解决了 问题是在本地通过 cap 这样调用的貌似是服务器自带的 ruby 1.9.2;然后在服务器端就调用 rvm 安装的 2.0 版本的 ruby; 用 rvm-capistrano 就可以让 cap 选择 rvm 的 ruby 了。 谢啦!

#4 楼 @autumnwolf 谢谢反馈,原来问题是出在这里。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号