6

I'm trying to run the following command on my remote server (either via capistrano or ssh):

bundle exec RAILS_ENV=production script/delayed_job start

But I'm getting this error message: bundler: not executable: script/delayed_job

Never saw this before, and google had nothing for me. Any idea what might be the problem?

hananamar
  • 1,166
  • 15
  • 25
  • Thanks @stanislav, apparently the problem is that deploying with capistrano from windows doesnt set any files as executable. I'm not sure if it's capistrano or windowws or both, but setting permissions solved the problem – hananamar Nov 18 '14 at 07:04

2 Answers2

13

Maybe it does not have permissions to run? Try running this command

chmod +x script/delayed_job

and then executing the file again.

patrickbadley
  • 2,510
  • 2
  • 29
  • 30
Stanislav Mekhonoshin
  • 4,276
  • 2
  • 20
  • 25
  • 1
    I have to run this everytime. Is there a way to make this permission to run permanent set to my capistrano `deploy` user? – Jay Killeen Sep 16 '19 at 21:55
2

I am not sure if if it is a fundamental misunderstanding of the capistrano rbenv gem or some issue with the gem itself, but I had similar issue with delayed_job, where the bin/delayed_job file just would not get the executable permission when copied to the server by capistrano. So I wrote a task which I had run before invoking the delayed_job:restart task.

Note - Adding this answer because earlier one is from 2014, and also I wanted to show how to add the task, so the permission change can happen during deployment itself.

Created a task in lib/capistrano/tasks folder (in namespace delayed_job):

namespace :delayed_job do
  desc 'Ensure that bin/delayed_job has the permission to be executable. Ideally, this should not have been needed.'
    task :ensure_delayed_job_executable do
      on roles(delayed_job_roles) do
        within release_path do
          execute :chmod, :'u+x', :'bin/delayed_job'
        end
    end
  end
end

after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
  task :restart do
    invoke 'delayed_job:ensure_delayed_job_executable'
    invoke 'delayed_job:restart'
  end
end
arunt
  • 346
  • 3
  • 15
  • It is nice to find answers that have no votes yet, and it works. Worth to notice the after rails 4 we have bin/delayed job as you described in this post - as a difference to previous post that was refering to rails 3.x using script/delay_job – Adam Piotrowski May 07 '21 at 10:17