Capistrano RVM和Ubuntu RVM不是一个功能,用'rvm use ...'选择红宝石是行不通的

时间:2022-06-24 12:52:39

I'm trying to deploy my app for the first time on a ubuntu server.

我正在尝试在ubuntu服务器上第一次部署我的应用程序。

I keep hitting this error:

我一直在遇到这个错误:

 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.

Here's some of my deploy.rb file:

这是我的一些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 is installed on my server.

RVM安装在我的服务器上。

$ which rvm
/usr/local/rvm/bin/rvm
$ which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby

Any help is appreciated. I've been googling this one for days.

任何帮助表示赞赏。我一直在谷歌上搜索这个。

EDIT

编辑

I've uninstalled my multiuser installation of RVM and reinstalled the single user version.

我已卸载多用户安装的RVM并重新安装了单用户版本。

I added this line to my deploy.rb script: set :default_shell, "/bin/bash --login" # required for rvm scripts to work properly

我将此行添加到我的deploy.rb脚本中:set:default_shell,“/ bin / bash --login”#rvm脚本正常工作所需

and now i do not get the "RVM is not a function...." error.

现在我没有得到“RVM不是函数....”错误。

The problem is that when bundle install runs, the gems are not installed in my rvm gemset.

问题是当捆绑安装运行时,我的rvm gemset中没有安装gem。

5 个解决方案

#1


2  

In my deploy.rb file, setting this line:

在我的deploy.rb文件中,设置此行:

set :bundle_dir, "/usr/local/rvm/gems/ruby-1.9.3-p392"

before this line:

在此之前:

require 'bundler/capistrano'

seemed to help bundler know where to install the gems. Not sure why this is needed. I've never needed it before.

似乎帮助捆绑者知道在哪里安装宝石。不知道为什么需要这样做。我以前从未需要它。

#2


1  

  1. Don't use rvm1/capistrano3 or rvm/capistrano; don't set :pty.

    不要使用rvm1 / capistrano3或rvm / capistrano;不设置:pty。

  2. Change ~/.rvmrc for the runner user, on the server, to this — note that it has to come before the line where it kills itself when not running interactively:

    将服务器上的转轮用户的〜/ .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 

#3


1  

I've just been struggling with this issue. Tried everything listed above, nothing worked. Deploying from osx, to ubuntu.

我一直在努力解决这个问题。尝试了上面列出的一切,没有任何效果。从osx部署到ubuntu。

Finally, on ubuntu, "su-ed" as my deploy user, I did "rvm get head" (where I had been using "rvm get stable"). (I have it setup in a single-user environment, with rvm under "/home/deploy/.rvm".)

最后,在ubuntu上,“su-ed”作为我的部署用户,我做了“rvm get head”(我一直在使用“rvm get stable”)。 (我在单用户环境中设置它,rvm在“/home/deploy/.rvm”下。)

Like magic, it started working! Phew. So I guess maybe there's some fix in the latest rvm, that isn't in stable yet?

像魔术一样,它开始工作了!唷。所以我想也许在最新的rvm中有一些修复,那还不稳定吗?

#4


0  

Maybe you need to add the RVM bin directory to your $PATH for scripting:

也许您需要将RVM bin目录添加到$ PATH以进行脚本编写:

PATH=$PATH:$HOME/.rvm/bin

#5


0  

Although it seems you've answered your own question, I'll throw my hat in the ring as well...
I had a similar issue with the whole RVM is not a function error when trying to create a Rails template, and got around it by getting the rvm environment instance on a specific Ruby version, and then setting the gemset/running bundle install directly on it. In your case, it may be something like:

虽然看起来你已经回答了自己的问题,但我也会把我的帽子放在戒指中......我在整个RVM中遇到类似的问题,在尝试创建Rails模板时并不是函数错误通过在特定的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

Obviously, the above code is not tested, but I created similar code that I've had success with in this Rails template file that will hopefully serve as some reference to you if the above code completely fails.

显然,上面的代码没有经过测试,但是我在这个Rails模板文件中创建了类似的代码,如果上面的代码完全失败,它将有希望作为一些参考。

#1


2  

In my deploy.rb file, setting this line:

在我的deploy.rb文件中,设置此行:

set :bundle_dir, "/usr/local/rvm/gems/ruby-1.9.3-p392"

before this line:

在此之前:

require 'bundler/capistrano'

seemed to help bundler know where to install the gems. Not sure why this is needed. I've never needed it before.

似乎帮助捆绑者知道在哪里安装宝石。不知道为什么需要这样做。我以前从未需要它。

#2


1  

  1. Don't use rvm1/capistrano3 or rvm/capistrano; don't set :pty.

    不要使用rvm1 / capistrano3或rvm / capistrano;不设置:pty。

  2. Change ~/.rvmrc for the runner user, on the server, to this — note that it has to come before the line where it kills itself when not running interactively:

    将服务器上的转轮用户的〜/ .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 

#3


1  

I've just been struggling with this issue. Tried everything listed above, nothing worked. Deploying from osx, to ubuntu.

我一直在努力解决这个问题。尝试了上面列出的一切,没有任何效果。从osx部署到ubuntu。

Finally, on ubuntu, "su-ed" as my deploy user, I did "rvm get head" (where I had been using "rvm get stable"). (I have it setup in a single-user environment, with rvm under "/home/deploy/.rvm".)

最后,在ubuntu上,“su-ed”作为我的部署用户,我做了“rvm get head”(我一直在使用“rvm get stable”)。 (我在单用户环境中设置它,rvm在“/home/deploy/.rvm”下。)

Like magic, it started working! Phew. So I guess maybe there's some fix in the latest rvm, that isn't in stable yet?

像魔术一样,它开始工作了!唷。所以我想也许在最新的rvm中有一些修复,那还不稳定吗?

#4


0  

Maybe you need to add the RVM bin directory to your $PATH for scripting:

也许您需要将RVM bin目录添加到$ PATH以进行脚本编写:

PATH=$PATH:$HOME/.rvm/bin

#5


0  

Although it seems you've answered your own question, I'll throw my hat in the ring as well...
I had a similar issue with the whole RVM is not a function error when trying to create a Rails template, and got around it by getting the rvm environment instance on a specific Ruby version, and then setting the gemset/running bundle install directly on it. In your case, it may be something like:

虽然看起来你已经回答了自己的问题,但我也会把我的帽子放在戒指中......我在整个RVM中遇到类似的问题,在尝试创建Rails模板时并不是函数错误通过在特定的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

Obviously, the above code is not tested, but I created similar code that I've had success with in this Rails template file that will hopefully serve as some reference to you if the above code completely fails.

显然,上面的代码没有经过测试,但是我在这个Rails模板文件中创建了类似的代码,如果上面的代码完全失败,它将有希望作为一些参考。