bin/bash: ruby command not found. Ruby not in sudo path

I have faced the same issue and fumbled to find an answer. here is how I solved it.

  • start the program with the following shibang line so that ubuntu knows it is a ruby file. #!/usr/bin/env ruby
  • change the directory to where your code lives cd /home/User1/program
  • make your file executable by running chmod +x your_program.rb
  • type in the terminal ruby your_program.rb notice the text "ruby"