Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ruby can't dup Fixnum

I have some code like this

ssh_files = ["id_rsa.pub","id_rsa"]
ssh_files.each_with_index do |item, index|
      ssh_files[index] =  generate_ssh_path(creator).concat(item)
      FileUtils.mkdir_p(ssh_files[index], 0770) unless File.exists?(generate_ssh_path(creator))

end and I get this error message

TypeError (can't dup Fixnum):
  command.rb:45:in `block in generate_ssh_key'
  command.rb:42:in `each'
  command.rb:42:in `each_with_index'

Edit here's the stack

TypeError (can't dup Fixnum):
  command.rb:44:in `block in generate_ssh_key'
  command.rb:42:in `each'
  command.rb:42:in `each_with_index'
  command.rb:42:in `generate_ssh_key'
  key.rb:14:in `create_key'
  key.rb:10:in `initialize'
  app/models/user.rb:207:in `new'
  app/models/user.rb:207:in `ssh_key'
like image 877
user1611830 Avatar asked Dec 29 '25 01:12

user1611830


1 Answers

Options to mkdir_p are supposed to be a Hash, since it accepts a variety of options, so call it this way:

FileUtils.mkdir_p(ssh_files[index], :mode => 0770)
like image 147
lurker Avatar answered Dec 30 '25 14:12

lurker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!