Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundler: failed to load command: whenever #853

Closed
rachitpant opened this issue May 8, 2024 · 2 comments
Closed

Bundler: failed to load command: whenever #853

rachitpant opened this issue May 8, 2024 · 2 comments

Comments

@rachitpant
Copy link

I am getting an error when trying to run cap staging whenever:update_crontab.
The error is:


SSHKit::Command::Failed: bundle exit status: 1
bundle stdout: Nothing written
bundle stderr: bundler: failed to load command: whenever (/var/www/tennis/shared/bundle/ruby/3.1.0/bin/whenever)
/usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/rubygems_integration.rb:319:in `block in replace_bin_path': can't find executable whenever for gem whenever. whenever is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/rubygems_integration.rb:347:in `block in replace_bin_path'
        from /var/www/tennis/shared/bundle/ruby/3.1.0/bin/whenever:25:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli.rb:484:in `exec'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli.rb:25:in `start'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:48:in `block in <top (required)>'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
        from /usr/local/rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:36:in `<top (required)>'
        from /usr/local/rvm/gems/ruby-3.1.2/bin/bundle:25:in `load'
        from /usr/local/rvm/gems/ruby-3.1.2/bin/bundle:25:in `<main>'
/Users/rpant/.rvm/gems/ruby-3.1.2@tennis_lineups/gems/sshkit-1.21.3/lib/sshkit/command.rb:97:in `exit_status='
/Users/rpant/.rvm/gems/ruby-3.1.2@tennis_lineups/gems/sshkit-1.21.3/lib/sshkit/backends/netssh.rb:170:in `execute_command'
/Users/rpant/.rvm/gems/ruby-3.1.2@tennis_lineups/gems/sshkit-1.21.3/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
<internal:kernel>:90:in `tap'
/Users/rpant/.rvm/gems/ruby-3.1.2@tennis_lineups/gems/sshkit-1.21.3/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
/Users/rpant/.rvm/gems/ruby-3.1.2@tennis_lineups/gems/sshkit-1.21.3/lib/sshkit/backends/abstract.rb:80:in `execute'
/Users/rpant/.rvm/gems/ruby-3.1.2@tennis_lineups/gems/whenever-1.0.0/lib/whenever/capistrano/v3/tasks/whenever.rake:9:in `block (3 levels) in setup_whenever_task'
/Users/rpant/.rvm/gems/ruby-3.1.2@tennis_lineups/gems/sshkit-1.21.3/lib/sshkit/backends/abstract.rb:100:in `with'

As you can tell , i am using rvm. On the local machine i am using a gemset (tennis_lineups) with the rvm , but there is no gemset being use on the server. The ruby environment is the same 3.1.2.

The deploy.rb file has

set :rvm_ruby_version, "3.1.2"
set :rvm_type, :system
set :whenever_environment, -> { fetch(:stage) }
set :whenever_identifier, -> { "#{fetch(:application)}_#{fetch(:stage)}" }

And this is my schedule.rb file

set :output, "/mnt/appdata/cronjobs/tennis-import/tennis_import.log"
ENV.each { |k, v| env(k, v) }
job_type :rake, "rvm use && cd :path && RAILS_ENV=:environment rake :task --silent :output"

every :sunday, :monday, :saturday, at: '3:00 am' do
  rake "jobs:trigger_tennis_import_job[arg1=ALL,arg2=3,arg3=2023-08-01]"
end

every :thursday, at: '7:00 pm' do
  rake "jobs:trigger_tennis_import_job[arg1=ALL,arg2=3,arg3=2023-08-01,arg4=nil,arg5=true]"
end

This gem seems like a great solution , except that i cant get it working. and 2) even if i get it working , we use a seperate cron server for production ( different from app server ) , so not sure how to go about it.

@rachitpant
Copy link
Author

I will also add that whenever is installed on the server at the location /var/www/tennis/shared/bundle/ruby/3.1.0/bin/ . So not sure why bunder can't load it.

@rachitpant
Copy link
Author

Not sure what's different , but i was able to have this gem update the crontab , one change i made was to comment out the deploy hook the first time , and then uncommented it again, Although i think we possibly dont even need this anymore.
after 'deploy:restart', 'whenever:update_crontab'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant