Bundler 试图 运行 在 Ruby 的错误版本下
Bundler Trying To Run Under Wrong Version of Ruby
我有一个 rails 站点,我使用 git post-receive 挂钩通过 ssh 部署它。当我通过 ssh 进入服务器并 运行 捆绑包将它 运行 正确安装在指定的 ruby 版本 2.2.2 下。然而,当我从我的本地机器推送到服务器并且它命中 'bundle install command' 时,我得到以下信息:
hooks/post-receive: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory
我怎么也找不到它指向 ruby1.9.1 的原因。该目录不存在。我确实在该目录中看到了 ruby2.3 的目录,但没有看到 ruby2.2.2,这是正确的目录。有些东西很糟糕,但我不知道如何修复它。有人见过这样的东西吗?
更新:这是我的 post-receive 钩子,根据下面的请求...
#!/bin/bash
GIT_DIR=/home/deploy/www_production
WORK_TREE=/home/deploy/www
export MGOTS_DATABASE_USER='user'
export MGOTS_DATABASE_PASSWORD='pass'
export RAILS_ENV="production"
. ~/.bash_profile
while read oldrev newrev ref
do
if [[ $ref = refs/heads/master ]];
then
echo "Master ref received. Deploying master branch to production..."
mkdir -p $WORK_TREE
git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f
mkdir -p $WORK_TREE/shared/pids $WORK_TREE/shared/sockets $WORK_TREE/shared/log
# start deploy tasks
cd $WORK_TREE
bundle install
rake db:create
rake db:migrate
rake assets:precompile
rake requests:cleanup
sudo restart puma-manager
sudo service nginx restart
# end deploy tasks
echo "Git hooks deploy complete"
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
更新:为了清楚起见,由于答案指向找到答案的正确位置,但没有准确说明,我在这里 post 更新我的挂钩文件。你可以看到这个和上面那个之间的区别,这就是解决问题的原因。请注意,可以通过键入以下命令找到 rvm 目录的路径:which rvm - 这就是您要指向的那个。
#!/bin/bash
GIT_DIR=/home/deploy/www_production
WORK_TREE=/home/deploy/www
export MGOTS_DATABASE_USER='user'
export MGOTS_DATABASE_PASSWORD='pass'
export RAILS_ENV="production"
export RUBYGEMS_GEMDEPS="/home/deploy/.rvm/ruby-2.2.2@www/gems"
. ~/.bash_profile
[[ -s "/usr/share/rvm/bin/rvm" ]] && source "/usr/share/rvm/bin/rvm"
while read oldrev newrev ref
do
if [[ $ref = refs/heads/master ]];
then
echo "Master ref received. Deploying master branch to production..."
mkdir -p $WORK_TREE
git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f
mkdir -p $WORK_TREE/shared/pids $WORK_TREE/shared/sockets $WORK_TREE/shared/log
# start deploy tasks
cd $WORK_TREE
bundle install
rake db:create
rake db:migrate
rake assets:precompile
rake requests:cleanup
sudo restart puma-manager
sudo service nginx restart
# end deploy tasks
echo "Git hooks deploy complete"
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
首先,将默认 ruby 设置为使用版本 2.2.2
您在使用 RVM 吗?对于 RVM 其:rvm use --default 2.2.2
您需要将 RVM 函数加载到 shell 脚本。 link
或者只是切换到 Rbenv :)
我有一个 rails 站点,我使用 git post-receive 挂钩通过 ssh 部署它。当我通过 ssh 进入服务器并 运行 捆绑包将它 运行 正确安装在指定的 ruby 版本 2.2.2 下。然而,当我从我的本地机器推送到服务器并且它命中 'bundle install command' 时,我得到以下信息:
hooks/post-receive: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory
我怎么也找不到它指向 ruby1.9.1 的原因。该目录不存在。我确实在该目录中看到了 ruby2.3 的目录,但没有看到 ruby2.2.2,这是正确的目录。有些东西很糟糕,但我不知道如何修复它。有人见过这样的东西吗?
更新:这是我的 post-receive 钩子,根据下面的请求...
#!/bin/bash
GIT_DIR=/home/deploy/www_production
WORK_TREE=/home/deploy/www
export MGOTS_DATABASE_USER='user'
export MGOTS_DATABASE_PASSWORD='pass'
export RAILS_ENV="production"
. ~/.bash_profile
while read oldrev newrev ref
do
if [[ $ref = refs/heads/master ]];
then
echo "Master ref received. Deploying master branch to production..."
mkdir -p $WORK_TREE
git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f
mkdir -p $WORK_TREE/shared/pids $WORK_TREE/shared/sockets $WORK_TREE/shared/log
# start deploy tasks
cd $WORK_TREE
bundle install
rake db:create
rake db:migrate
rake assets:precompile
rake requests:cleanup
sudo restart puma-manager
sudo service nginx restart
# end deploy tasks
echo "Git hooks deploy complete"
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
更新:为了清楚起见,由于答案指向找到答案的正确位置,但没有准确说明,我在这里 post 更新我的挂钩文件。你可以看到这个和上面那个之间的区别,这就是解决问题的原因。请注意,可以通过键入以下命令找到 rvm 目录的路径:which rvm - 这就是您要指向的那个。
#!/bin/bash
GIT_DIR=/home/deploy/www_production
WORK_TREE=/home/deploy/www
export MGOTS_DATABASE_USER='user'
export MGOTS_DATABASE_PASSWORD='pass'
export RAILS_ENV="production"
export RUBYGEMS_GEMDEPS="/home/deploy/.rvm/ruby-2.2.2@www/gems"
. ~/.bash_profile
[[ -s "/usr/share/rvm/bin/rvm" ]] && source "/usr/share/rvm/bin/rvm"
while read oldrev newrev ref
do
if [[ $ref = refs/heads/master ]];
then
echo "Master ref received. Deploying master branch to production..."
mkdir -p $WORK_TREE
git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f
mkdir -p $WORK_TREE/shared/pids $WORK_TREE/shared/sockets $WORK_TREE/shared/log
# start deploy tasks
cd $WORK_TREE
bundle install
rake db:create
rake db:migrate
rake assets:precompile
rake requests:cleanup
sudo restart puma-manager
sudo service nginx restart
# end deploy tasks
echo "Git hooks deploy complete"
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
首先,将默认 ruby 设置为使用版本 2.2.2
您在使用 RVM 吗?对于 RVM 其:rvm use --default 2.2.2
您需要将 RVM 函数加载到 shell 脚本。 link 或者只是切换到 Rbenv :)