簡體   English   中英

無法使用capistrano部署rails4項目。 rbenv:未安裝版本“2.0.0”

[英]Can't deploy rails4 project with capistrano. rbenv: version `2.0.0' is not installed

將rails4應用程序部署到VPS時出錯。 我得到的錯誤是

rbenv: version `2.0.0' is not installed

但是使用“ruby -v”我得到了

ruby 2.0.0p0 (2013-02-24 revision 39474) [i686-linux]

在我的gemfile中我有

source 'https://rubygems.org'

ruby '2.0.0'
gem 'rails', '4.0.0'

捆綁安裝配方后出現此錯誤

2013-08-04 23:23:56 executing `bundle:install'
* executing "cd /home/yasinishyn/apps/kaiser/releases/20130804202355 && bundle install --gemfile /home/yasinishyn/apps/kaiser/releases/20130804202355/Gemfile --path /home/yasinishyn/apps/kaiser/shared/bundle --deployment --quiet --without development test"
servers: ["xxx.xxx.xxx.xxx"]
[198.211.125.183] executing command
** [out :: xxx.xxx.xxx.xxx] rbenv: version `2.0.0' is not installed
** [out :: xxx.xxx.xxx.xxx] 
command finished in 355ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/yasinishyn/apps/kaiser/releases/20130804202355; true"
servers: ["xxx.xxx.xxx.xxx"]
[xxx.xxx.xxx.xxx] executing command
command finished in 342ms

請幫我解決這個問題。

謝謝本傑明,但錯誤真的很愚蠢))。 Localy我使用由rvm安裝的ruby 2.0.0-p195。 在我的服務器上我用rickv安裝的ruby 2.0.0-p0,因為rbenv沒有ruby軟件包2.0.0-p195。

因此,當我使用rails-composer創建新的rails4應用程序時,我沒有注意到它是使用.ruby-version文件創建的,其中的內容是ruby版本的ruby 2.0.0-p195 ,所以我只是* git rm .ruby-version * ,一切正常。

這肯定是一個PATH問題,capistrano將通過ssh發送命令而不打開控制台會話,如果你打開一個ssh控制台會話,配置文件不會以相同的方式加載。 這可以解釋為什么通過ssh控制台你可以獲得正確的rbenv環境,但不能通過capistrano。

以下適用於debian / ubuntu,需要針對其他發行版進行調整

我想你在你的一個配置文件中添加了一些export指令。 或許在〜/ .profile或〜/ .bashrc中。

我使用的export說明如下,但它們在您的配置中可能有所不同,因此如果在打開ssh控制台時rbenv正常工作,那么您可以保留一組export命令。 我要詳細說明的訣竅就是將它們放在正確的位置。

我的export說明是:

echo 'export RBENV_ROOT=/opt/rbenv'
echo 'export PATH=/opt/rbenv/bin:$PATH'
echo 'eval "$(rbenv init -)"'

1-

將它們從您之前包含它們的任何文件中刪除,並將它們放在文件/etc/profile.d/rbenv中

2-

編輯文件/root/.bashrc(或/home/your_user/.bashrc如果您使用“root”之外的其他用戶訪問您的服務器)並在行[ -z "$PS1" ] && return之前添加行source /etc/profile.d/rbenv [ -z "$PS1" ] && return

3-

編輯文件/home/deployer/.bashrc(假設您使用“deployer”用戶為capistrano,否則調整路徑)並在行[ -z "$PS1" ] && return之前添加行source /etc/profile.d/rbenv [ -z "$PS1" ] && return

4-

通過打開另一個ssh控制台會話並嘗試ruby -v驗證它是否正常工作。 然后capistrano應該正常工作

其他可能性

手動安裝gem后rbenv需要rehash,所以在你的服務器rbenv rehash上運行只是為了確定

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM