0

I used some code from a github based which is used to handle testing and compiling of code. In it there is an extension to the command available to Ceedling (The test harness that I will be using) which uses Ruby in a file called "rakefile.rb".

I am trying to run the following command:

desc "Convert the output binary to a hex file"
task :convert => :release do
  cmd = "\"C:/Program Files (x86)/Microchip/xc16/v1.23/bin\"\\\\xc16-bin2hex ./build/release/Output.elf -a -omf=elf"
  puts "Generating Output.hex..."
  puts cmd
  sh cmd
end

If I put the code, below, in to my "Start Command Prompt With Ruby" program, then the output is correct and the action is taken:

"C:/Program Files (x86)/Microchip/xc16/v1.23/bin"\\xc16-bin2hex ./build/release/Output.elf -a -omf=elf

If I don't include the \" and the \'s then the program will not work.

At present I get the output:

Generating Output.hex...
"C:/Program Files (x86)/Microchip/xc16/v1.23/bin"\\xc16-bin2hex ./build/release/Output.elf -a -omf=elf
rake aborted!
Command failed with status (127): ["C:/Program Files (x86)/Microchip/xc16/v1....]
rakefile.rb:16:in `block in <top (required)>'
C:/Ruby24-x64/bin/ceedling:23:in `load'
C:/Ruby24-x64/bin/ceedling:23:in `<main>'
Tasks: TOP => convert
(See full trace by running task with --trace)

What am I doing wrong and where can I read more about the basics of Ruby?

GMoney
  • 139
  • 1
  • 11
  • first step would be to run it with the ```--trace``` flag as the error message suggests. If I had to guess I'd say it's an issue with the file path and escape characters i.e. forward slashes vs back slashes – ConorSheehan1 Jun 07 '18 at 14:30
  • Shouldn't the file path use backslashes for windows? i.e ```C:\Program Files (x86)\Microchip\xc16\v1.23\bin``` Or are you using cygwin or some other unix like terminal? – ConorSheehan1 Jun 07 '18 at 14:33
  • How do i use the trace facility? I have tried Ceedling convert --trace and all the combinations of that but it's not recognized Also using the backslashes makes no difference to the output. I am using Command Prompt with Ruby – GMoney Jun 07 '18 at 14:35
  • I'm not sure what Ceedling is, but this looks like a rake task, so I'd use ```bundle exec rake $your_task_name --trace``` or drop the bundle exec portion if you aren't using bundler – ConorSheehan1 Jun 07 '18 at 14:38
  • Ceedling does use rake. I get 'exec is not recognized as an internal or external command, operable program or batch file' It can't locate a bundle – GMoney Jun 07 '18 at 14:40
  • Did you try dropping the bundle exec part? ```rake $your_task_name --trace``` – ConorSheehan1 Jun 07 '18 at 15:17
  • Yeah I get `rake $Ceedling convert --trace rake aborted! Don't know how to build task '$Ceedling' (see --tasks) C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rake-12.0.0/lib/rake/task_manager.rb:58:in `[]' in `invoke_task' in `block (2 levels) in top_level' in `each' in `block in top_level' in `run_with_threads' in `top_level' in `block in run' in `standard_exception_handling' in `run' in `' in `load' in `
    '`` I'm sorry I can't format it
    – GMoney Jun 07 '18 at 15:21
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/172700/discussion-between-con-and-gmoney). – ConorSheehan1 Jun 07 '18 at 15:27

1 Answers1

1

From the error you posted in the chat it looks like the root issue is the rake task not finding sh,
which is an executable that runs a linux shell scripting language.

I'd say the easiest option is to either

  1. install sh on windows via cygwin, mingw or gitbash (see this answer)

    or

  2. Run linux on a vm or container

Community
  • 1
  • 1
ConorSheehan1
  • 1,640
  • 1
  • 18
  • 30