![](/img/trans.png)
[英]Bundle complaining about path of local gem on remote server when deploying
[英]Cannot run bundle command on remote server from local computer
我创建了一个脚本,将 tar 文件复制到远程服务器,做一些事情然后运行:
[..]
kill $(lsof -i :3000 -t)
# Bundle up
cd $DIR && \
bundle install && \
RAILS_ENV=production bundle exec rake assets:precompile && \
rails s -e production -p 3000 -d
我是否应该直接在远程服务器上运行它./my-script.sh param
,一切都很好。 当我从本地计算机调用此脚本时,它不起作用。 它抱怨
./my-script.sh:第 18 行:捆绑:找不到命令
当我在远程服务器上运行which bundle
时,我回来了:
/usr/share/rvm/gems/ruby-3.0.0/bin/bundle
在我的脚本中使用上面的内容我得到了大量的错误。 从本地计算机调用脚本时如何通过该错误?
您应该将所有 ruby 和 bundler env 变量设置为使用bundle exec
如果使用 rvm,您应该加载它:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
尝试通过以下方式了解 ruby 用户下服务器上 rvm 的所有 env: rvm env
它像ssh example.com <./bundle.sh
#!/bin/bash +ex
# bundle.sh
export PATH="/home/user/.rvm/gems/ruby-2.6.4/bin:/home/user/.rvm/gems/ruby-2.6.4@global/bin:/home/user/.rvm/rubies/ruby-2.6.4/bin:$PATH"
export GEM_HOME='/home/user/.rvm/gems/ruby-2.6.4'
export GEM_PATH='/home/user/.rvm/gems/ruby-2.6.4:/home/user/.rvm/gems/ruby-2.6.4@global'
export MY_RUBY_HOME='/home/user/.rvm/rubies/ruby-2.6.4'
export IRBRC='/home/user/.rvm/rubies/ruby-2.6.4/.irbrc'
unset MAGLEV_HOME
unset RBXOPT
export RUBY_VERSION='ruby-2.6.4'
source "$HOME/.rvm/scripts/rvm"
export RAILS_ENV=production
cd /path/ && bundle exec rails db:migrate:status
cd $DIR && \
bundle install && \
bundle exec rake assets:precompile && \
rails s -e production -p 3000 -d
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.