9
cmd = "snv co #{rep} --username #{svn_user} --password #{pxs}" 

puts cmd  # this code wotks and prints all vars values normally

exec(cmd)   
xpto.rb:69:in `exec': string contains null byte (ArgumentError)
    from xpto.rb:69
$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]
$ gem -v
1.3.7

Whats going on? How can I solve this?

1 Answer 1

12

Your cmd string has got a null (i.e. zero) byte in it somehow. Using puts won’t show up any null bytes, they’ll just be left out of the output:

1.8.7 :001 > exec "\0"
ArgumentError: string contains null byte
        from (irb):1:in `exec'
        from (irb):1
1.8.7 :002 > puts "n\0n"
nn
 => nil 

You should probably check how your rep, svn_user and pxs variables are being populated to see if you can track down the source of these null bytes, but as a quick fix you could use gsub! to remove them:

cmd.gsub!(/\0/, '')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.