我试图在Ubuntu服务器上首次部署我的应用程序。
我一直打这个错误:
2013-03-24 15:13:36 executing `deploy:run_migrations' * executing "rvm gemset use vapin" servers: ["111.111.111.11"] [111.111.111.11] executing command ** [out :: 111.111.111.11] ** [out :: 111.111.111.11] ** [out :: 111.111.111.11] RVM is not a function, selecting rubies with 'rvm use ...' will not work. ** [out :: 111.111.111.11] ** [out :: 111.111.111.11] ** [out :: 111.111.111.11] ** [out :: 111.111.111.11] You need to change your terminal emulator preferences to allow login shell. ** [out :: 111.111.111.11] ** [out :: 111.111.111.11] Sometimes it is required to use `/bin/bash --login` as the command. ** [out :: 111.111.111.11] ** [out :: 111.111.111.11] Please visit https://rvm.io/integration/gnome-terminal/ for a example.
这是我的一些deploy.rb文件:
require 'bundler/capistrano' require 'rvm/capistrano' # set the ruby version #set :rvm_ruby_string, 'ruby-1.9.3-p392' #set :rvm_type, :system # set the rvm gemset to use set :rvm_gemset, 'vapin' ... task :install do run "rvm gemset use #{rvm_gemset}" run "cd #{current_path} && bundle install --without=test" end
RVM安装在我的服务器上。
$ which rvm /usr/local/rvm/bin/rvm $ which ruby /usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby
任何帮助表示赞赏。 我一直在search这个天。
编辑
我卸载了RVM的多用户安装并重新安装了单用户版本。
我将这一行添加到了我的deploy.rb脚本中:set:default_shell,“/ bin / bash –login”#rvm脚本需要正常工作
现在我没有得到“RVM不是一个函数….”的错误。
问题是当bundle安装运行时,gem没有安装在我的rmm gemset中。
在我的deploy.rb文件中,设置这一行:
set :bundle_dir, "/usr/local/rvm/gems/ruby-1.9.3-p392"
在这行之前:
require 'bundler/capistrano'
似乎帮助打包者知道在哪里安装宝石。 不知道为什么这是必要的。 我从来没有需要它。
不要使用rvm1 / capistrano3或rvm / capistrano; 不要设置:pty。
将服务器上的runner用户的~/.rvmrc
更改为 – 请注意,如果不以交互方式运行,它必须位于其自身被~/.rvmrc
的行之前 :
# get rvm for non-interactive shells (eg capistrano) too source /etc/profile.d/rvm.sh export BASH_ENV=$HOME/.bashrc export rvm_is_not_a_shell_function=0 # If not running interactively, don't do anything [ -z "$PS1" ] && return
我刚刚一直在努力解决这个问题。 试了上面列出的一切,没有任何工作。 从osx部署到Ubuntu。
最后,在Ubuntu上,“su-ed”作为我的部署用户,我做了“rvm get head”(我一直使用“rvm get stable”)。 (我已经在单用户环境中进行了设置,在“/home/deploy/.rvm”下有rvm)。
像魔术一样,它开始工作! 唷。 所以我想也许在最新的rvm中有一些修复,那不是稳定的呢?
也许您需要将RVM bin目录添加到您的$PATH
脚本中:
PATH=$PATH:$HOME/.rvm/bin
虽然看起来你已经回答了你自己的问题,但我也会把我的帽子扔在戒指里面…
我有一个类似的问题,整个RVM is not a function
在创建Rails模板时RVM is not a function
错误,而是通过在特定的Ruby版本上获取rvm
环境实例,然后直接在其上设置gemset / running bundle install 。 在你的情况下,它可能是这样的:
require 'bundler/capistrano' require 'rvm/capistrano' # set the ruby version set :rvm_ruby_string, 'ruby-1.9.3-p392' # set the rvm gemset to use set :rvm_gemset, 'vapin' ... task :install do require 'rvm' env = RVM::Environment.new(rvm_ruby_string) # If you need to create a new app-specific gemset # env.gemset_create(rvm_gemset) env.gemset_use!(rvm_gemset) # If you need to install bundler in a new gemset # env.system("gem", "install", "bundler") env.system("bundle", "install", "--without=test") end
显然,上面的代码没有经过测试,但我创建了类似的代码,我已经在这个Rails模板文件中取得了成功,如果上面的代码完全失败,希望可以作为一些参考。