rbenv:bundle:在生产服务器上找不到命令
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rbenv:bundle:在生产服务器上找不到命令相关的知识,希望对你有一定的参考价值。
我正在尝试部署rails应用程序,但它坚持错误
DEBUG[1a70ba92] Command: cd /home/deploy/myapp/releases/20140615090226 && ( PATH=$HOME/.rbenv /shims:$HOME/.rbenv/bin:$PATH RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2 ~/.rbenv/bin/rbenv exec bundle install --binstubs /home/deploy/myapp/shared/bin --path /home/deploy/myapp/shared/bundle --without development test --deployment --quiet )
DEBUG[1a70ba92] rbenv: bundle: command not found
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xx: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: rbenv: bundle: command not found
deploy.rb
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'myapp'
set :repo_url, 'git@bitbucket.org:username/myapp.git'
# Default branch is :master
# ask :branch, proc `git rev-parse --abbrev-ref HEAD`.chomp
# Default deploy_to directory is /var/www/my_app
set :deploy_to, '/home/deploy/myapp'
# Default value for :scm is :git
# set :scm, :git
set :branch, "master"
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
# set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
set :linked_files, %wconfig/database.yml
# Default value for linked_dirs is []
set :linked_dirs, %wbin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system
# Default value for default_env is
# set :default_env, path: "/opt/ruby/bin:$PATH"
set :default_env, path: "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
# Default value for keep_releases is 5
# set :keep_releases, 5
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, :restart
end
desc "Symlink shared config files"
task :symlink_config_files do
run "# try_sudo ln -s # deploy_to /shared/config/database.yml # current_path /config/database.yml"
end
end
capfile
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails'
require 'capistrano/rbenv'
set :rbenv_ruby, "2.1.2"
Production.rb
set :stage, :production
role :app, %wdeploy@xxx.xxx.xxx.xx
role :web, %wdeploy@xxx.xxx.xxx.xx
role :db, %wdeploy@xxx.xxx.xxx.xx
set :password, ask('Server password', nil)
server 'xxx.xxx.xxx.xx', user: 'deploy', password: fetch(:password), roles: %wweb app
/etc/nginx/Nginx.conf
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deploy/.rbenv/shims/ruby;
在/ etc / nginx的/启用的站点 - /默认
server
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name mydomain.com;
passenger_enabled on;
rails_env production;
root /home/deploy/myapp/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html
root html;
which ruby
/home/deploy/.rbenv/shims/ruby
ruby -v
ruby 2.1.2p95
它使用正确的红宝石版本。但我想尝试在另一个文件夹中安装宝石。我该如何修复它?
您是否尝试首先在服务器上安装gem“bundler”?运行bundle命令需要此gem。 SSH到您的服务器并运行以下命令:
gem install bundler
希望有所帮助
如果你已经安装了bundler(bundler -v)试一试(它在Ubuntu 12.04 LTS上适用于我):
1. gem uninstall bundler
2. gem update
3. gem install bundler
4. redeploy
它对我有用。我正在使用Ubuntu 16.04.Change用户下面的用户名。
sudo pico /etc/profile.d/rbenv.sh
#File
export RBENV_ROOT=/home/user/.rbenv
export PATH=$RBENV_ROOT/shims:$RBENV_ROOT/bin:$PATH
#End File
更新: 我找到原因:我的.gemrc包含“gem:--user-install”,所以bundle不能安装在rbenv中,然后rbenv在2.1.2路径中找不到bundle二进制文件删除--user-install config ,并重新安装捆绑包resovle问题。
=================================== 我发现RBENV_VERSION env导致bundle失败,但不知道原因。我删除了RBENV_VERSION并在服务器上执行了cmd,它成功了。
如果你查看你的.bashrc或.bash_profile,你会看到类似的东西:
case $- in
*i*) ;;
*) return;;
esac
要么:
[ -z "$PS1" ] && return
如果shell不是交互式的,这将阻止执行此行之后的所有内容。
Capistrano不会打开交互式shell。
例如,如果您使用rbenv,它会在.bashrc的末尾添加行。这些行未执行,因此未加载ruby环境。
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
在上面解释的返回之前,只需在.bashrc的开头移动rbenv行。
以上是关于rbenv:bundle:在生产服务器上找不到命令的主要内容,如果未能解决你的问题,请参考以下文章
sqlserver复制延迟报”应用复制的命令时在订阅服务器上找不到该行“
除了 Spotify 登录重定向路径“在服务器上找不到”之外,生产 React 应用程序正常运行 [重复]
Django 表单在生产与 LH 上找不到正确的 ID int 增量
错误:在 Discord Bot 的命令处理程序上找不到模块