1

I have a job, the code is:

class Job
  @queue = :default

  class << self
    def perform
      temp_file = Rails.root.join('tmp', 'my_temp_file')
      return if File.exist?(temp_file)
      FileUtils.touch(temp_file)

      begin
        # ....
      ensure
        FileUtils.rm(temp_file)
      end
    end

It's perfectly fine on local, but fails on travis with:

Failure/Error: LateNotificationJob.perform
     Errno::ENOENT:
       No such file or directory @ rb_sysopen - /home/travis/build/something/something/tmp/my_temp_file

What is the solution? Please help!

Giovani
  • 211
  • 1
  • 2
  • 8
  • See: http://stackoverflow.com/questions/6566884/rubys-file-open-gives-no-such-file-or-directory-text-txt-errnoenoent-er/6566912#6566912 – E. Sambo Apr 12 '17 at 22:15

1 Answers1

0

tmp directory is probably not checked in to your repo, but your local copy of the repo has it. For travis, which starts blank, either some Rails initializer or another codepath needs to create that directory before attempting to create the file in that directory. Or you could simply checkin an empty tmp directory with your repo.

Here's similar question and answer - Heroku - how to write into "tmp" directory?

Rahul
  • 1,495
  • 1
  • 15
  • 25