首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >rbenv: bundle:在生产服务器上找不到命令

rbenv: bundle:在生产服务器上找不到命令
EN

Stack Overflow用户
提问于 2014-06-15 17:56:02
回答 5查看 8.9K关注 0票数 8

我正在尝试部署rails应用程序,但它被错误卡住了

代码语言:javascript
运行
复制
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

代码语言:javascript
运行
复制
# 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, %w{config/database.yml}

# Default value for linked_dirs is []
 set :linked_dirs, %w{bin 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

代码语言:javascript
运行
复制
# 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

代码语言:javascript
运行
复制
set :stage, :production
role :app, %w{deploy@xxx.xxx.xxx.xx}
role :web, %w{deploy@xxx.xxx.xxx.xx}
role :db,  %w{deploy@xxx.xxx.xxx.xx}
set :password, ask('Server password', nil)
server 'xxx.xxx.xxx.xx', user: 'deploy', password: fetch(:password), roles: %w{web app}

/etc/nginx/nginx.conf

代码语言:javascript
运行
复制
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deploy/.rbenv/shims/ruby;

/etc/nginx/sites enabled/default

代码语言:javascript
运行
复制
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

它正在使用正确的ruby version.But,我猜是试图在另一个folder.How中安装gem,我能修复它吗?

EN

回答 5

Stack Overflow用户

发布于 2014-06-15 21:40:34

你有没有试过先在你的服务器上安装gem "bundler“?这个gem是运行bundle命令所必需的。通过SSH连接到您的服务器,然后运行以下命令:

代码语言:javascript
运行
复制
gem install bundler

希望这能有所帮助

票数 12
EN

Stack Overflow用户

发布于 2014-12-14 06:14:49

如果你已经安装了bundler (bundler ),试试这个(它在我的Ubuntu12.04LTS上有效):

代码语言:javascript
运行
复制
1. gem uninstall bundler
2. gem update
3. gem install bundler
4. redeploy
票数 3
EN

Stack Overflow用户

发布于 2016-12-30 22:52:39

这对我很管用。我使用的是Ubuntu 16.04。用你的用户名更改下面的用户。

sudo pico /etc/profile.d/rbenv.sh

代码语言:javascript
运行
复制
#File
export RBENV_ROOT=/home/user/.rbenv
export PATH=$RBENV_ROOT/shims:$RBENV_ROOT/bin:$PATH
#End File
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24228464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档