简体   繁体   English

每当提供“ require”时:无法加载此类文件-生产服务器中的bundler / setup`错误

[英]Whenever give ``require': cannot load such file — bundler/setup` error in production server

Im trying to setup whenever gem in my Ubuntu 14.04 server. 我试图在我的Ubuntu 14.04服务器中安装gem。 In my local machine it works fine. 在我的本地计算机上,它工作正常。 I use capistrano to deploy the site. 我使用capistrano部署站点。 I use rbenv in the server. 我在服务器中使用rbenv。 But when installing passenger it installs Ruby 1.9 which I do not use. 但是当安装乘客时,它会安装我不使用的Ruby 1.9。 Only use rbenv. 仅使用rbenv。 Here's my shcedule.rb : 这是我的shcedule.rb:

set :output, "#{path}/log/cron.log"

every 30.minutes do
    runner 'UploadmailWorker.perform_async'
end

every 12.hours do
    runner 'SubscriptionWorker.perform_async'
end

every :month do
    runner 'PaysellerWorker.perform_async'
end

My deploy.rb : 我的deploy.rb:

set :default_environment, {
  'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}

set :whenever_roles,        ->{ :app }
set :whenever_command,      ->{ [:bundle, :exec, :whenever] }
set :whenever_command_environment_variables, ->{ {} }
set :whenever_identifier,   ->{ fetch :application }
set :whenever_environment,  ->{ fetch :rails_env, fetch(:stage, "production") }
set :whenever_variables,    ->{ "environment=#{fetch :whenever_environment}" }
set :whenever_update_flags, ->{ "--update-crontab #{fetch :whenever_identifier} --set #{fetch :whenever_variables}" }
set :whenever_clear_flags,  ->{ "--clear-crontab #{fetch :whenever_identifier}" }

namespace :deploy do

    desc 'Restart application'
    task :restart do
        on roles(:app), in: :sequence, wait: 5 do
            execute :touch, release_path.join('tmp/restart.txt')
        end
    end

    after :publishing, 'deploy:restart'
    after :finishing, 'deploy:cleanup'
end

After deploying, the whenever does not work. 部署后,everyever不起作用。 In the cron.log I find this error : 在cron.log中,我发现此错误:

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /home/deploy/istockseller/releases/20150519112817/config/boot.rb:3:in `<top (required)>'
        from bin/rails:7:in `require_relative'
        from bin/rails:7:in `<main>'

How can I fix that? 我该如何解决?

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:在'require'中

Don't be confused, by this line. 不要被这条线弄糊涂了。 This is ruby library that get to be install for every ubuntu instances, so you can execute ruby commands. 这是将为每个ubuntu实例安装的ruby库,因此您可以执行ruby命令。

You need cd to you project and install bundler. 您需要使用CD进行项目安装并安装捆绑器。

Run this. 运行这个。

cd /to/your/project
[sudo] gem install bundler
bundle install

Update info for rbenv Rbenv的更新信息

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Use ~/.bashrc on Ubuntu, or ~/.zshrc for Zsh 在Ubuntu上使用〜/ .bashrc,对于Zsh使用〜/ .zshrc

$ type rbenv
#=> "rbenv is a function"

I also had this error: 我也有这个错误:

custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)

after investigating the issue the PATH shell variable was diferent in the cronb job and did not had rbenv stuff in it 在研究了该问题之后,PATH shell变量在cronb作业中是不同的,并且其中没有rbenv内容

changed the crontab manually with crontab -e 使用crontab -e手动更改了crontab

and added at the crontab lines 并添加到crontab行

... && PATH = my_complete_path RAILS_ENV=production  bin/rails ... ... 

after that the cronjob started working ... 之后,cronjob开始工作...

I dont consider this a good answer but a hack to get it working. 我认为这不是一个很好的答案,但是要使其正常工作是不可行的。 Maybe it helps someone. 也许它可以帮助某人。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ruby on Rails:错误“require”:无法加载此类文件——bundler/setup (LoadError) - Ruby on Rails: Error `require': cannot load such file -- bundler/setup (LoadError) `require&#39;:无法加载此类文件-捆绑程序/安装程序(LoadError) - `require': cannot load such file — bundler/setup (LoadError) 需要“捆绑器”错误,无法加载此类文件 — 捆绑器 (LoadError) - require 'bundler' error, cannot load such file — bundler (LoadError) Rails服务器正常工作,Rails控制台无效。 `require&#39;:无法加载此类文件-捆绑程序/安装程序(LoadError)- - Rails server works, Rails console does not. `require': cannot load such file — bundler/setup (LoadError) - 运行cron job`require&#39;时出错:无法加载此类文件 - bundler / setup(LoadError) - Error running cron job `require': cannot load such file — bundler/setup (LoadError) Rails为什么给出“`require”:不能仅在生产服务器上加载这样的文件-单例? - Why does Rails give “`require': cannot load such file — singleton” only on production server? 无法启动Rails服务器,“没有这样的文件加载 - bundler / setup” - Cannot start Rails Server, “no such file to load — bundler/setup” docker apache passenger:错误无法加载此类文件捆绑程序/安装程序(LoadError) - docker apache passenger: error cannot load such file bundler/setup (LoadError) Passenger RVM错误:无法加载此类文件 - bundler / setup - Passenger RVM Error: cannot load such file — bundler/setup Pow和rbenv出错 - “无法加载此类文件 - bundler / setup” - Error with Pow and rbenv - “cannot load such file — bundler/setup”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM