Hello guys, i'm having an issue with my rails app deployed with docker. Every time app goes through a code using tempfile it raises an error .
system temporary path is not writable: /tmp 11:00:30 web.1 | /tmp is not writable: /tmp 11:00:30 web.1 | . is not writable: /rails 11:00:30 web.1 | 2024-07-22 11:00:30 +0000 Rack app ("POST /folders/dropzone_import" - (82.64.63.1)): #<ArgumentError: could not find a temporary directory>
ruby "3.0.2" gem "rails", "~> 7.1.3.1" on ubuntun 22.04
Ah, the /tmp it is referring to may be the system tmp folder. You may want to see if you can create the tempfile within your Rails folder's tmp. My thought is that the dockerfile is changing the user and this user doesn't have access to write there.
require 'fileutils'
unless Rails.env.development?
# force the whole app to use its own tmpdir
FileUtils.mkdir_p(Rails.root.join('tmp'))
ENV['TMPDIR'] = Rails.root.join('tmp').to_s
end
Something like this is in the Rails main's .dockerignore.
i have that. still not working. it keeps raising the same error with
in initializer fix everything