gpt4 book ai didi

ruby-on-rails - 为什么在使用 rake 调用 heroku toolbelt CLI 时会出现 RubyVersionMismatch?

转载 作者:行者123 更新时间:2023-12-04 05:52:56 24 4
gpt4 key购买 nike

我正在尝试执行 heroku来自 rake 任务的 CLI:

  1 task :call_heroku do     
2 `heroku pgbackups:url --remote staging`
3 end
bundle exec rake call_heroku返回以下输出:
        /home/joe/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/bundler/
definition.rb:390:in `validate_ruby!': Your Ruby version is 1.9.3,but your
Gemfile specified 2.1.0 (Bundler::RubyVersionMismatch)
from /home/joe/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/
bundler.rb:116:in `setup'
from /home/joe/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.1/lib/
bundler/setup.rb:17:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
--remote staging

正在执行 heroku pgbackups:url --remote staging从命令行返回预期的 URL。我的 rvm 或 heroku CLI 配置有问题吗?

环境细节:

rails 3.2.17

英雄:
joe@warpaint ~/dev/project (master) $ heroku version
heroku-toolbelt/2.39.0 (i686-linux) ruby/1.9.3

房车:
joe@warpaint ~/dev/project (master) $ rvm version

rvm 1.25.22 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]


joe@warpaint ~/dev/project (master) $ rvm list

rvm rubies

jruby-1.7.1 [ i386 ]
ree-1.8.7-2012.02 [ i686 ]
ruby-1.8.7-p374 [ i686 ]
ruby-1.9.2-p320 [ i686 ]
ruby-1.9.3-p0 [ i686 ]
ruby-1.9.3-p362 [ i686 ]
ruby-1.9.3-p392 [ i686 ]
ruby-1.9.3-p448 [ i686 ]
ruby-1.9.3-p484 [ i686 ]
ruby-2.0.0-p0 [ i686 ]
* ruby-2.0.0-p247 [ i686 ]
ruby-2.0.0-p353 [ i686 ]
ruby-2.0.0-p451 [ i686 ]
ruby-2.0.0-preview2 [ i686 ]
=> ruby-2.1.0 [ i686 ]
ruby-head [ i686 ]

# => - current
# =* - current && default
# * - default

ruby :
joe@warpaint ~/dev/project (master) $ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]

最佳答案

事实证明,这是一个打包程序问题。一些挖掘使我想到了这个问题:
https://github.com/bundler/bundler/issues/2355 ,由@indirect 解决并使用 Bundler.with_clean_env 提及(此命令上的 more)。

现在我上面的任务变成:

  1 task :call_heroku do     
2 Bundler.with_clean_env { p `heroku pgbackups:url --remote staging` }
3 end

一切都很好!

关于ruby-on-rails - 为什么在使用 rake 调用 heroku toolbelt CLI 时会出现 RubyVersionMismatch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23037148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com