Stpn
Stpn

Reputation: 6394

Cannot allocate memory error in Rails (when creating folder locally)

I have a Rails app that gives me this error once in a while:

 Errno::ENOMEM

Error is coming from this function:

   def create_folder
    new_dir = self.id.to_s
    working_dir = '/home/user/files/'
   # THIS LINE IS CAUSING THE ERROR:
    %x[cd #{working_dir} && mkdir #{new_dir}]
    working_dir = working_dir + new_dir + '/'
    self.working_dir = working_dir
   self.save!

This error is happening from controller, which upon creation of model calls the above mentioned function...

Would be really grateful if someone points out how to deal with it..

I cannot see any pattern in why it happens or when..

Upvotes: 0

Views: 364

Answers (1)

Stpn
Stpn

Reputation: 6394

Just for the record. The error went away the moment I started using Ruby's Dir.

So

%x[mkdir NNN] # THIS IS BAD
Dir.mkdir("BBB") # THIS IS GOOD.

Upvotes: 1

Related Questions