1

I can't seem to run any code on ruby with any text editor. This error is returned when code is run

/bin/bash: ruby: command not found
[Finished in 0.0s with exit code 127]
[shell_cmd: ruby "/home/user/Resume/ruby/WebScraper/redditscrape.rb"]
[dir: /home/user/Resume/ruby/WebScraper]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/user/.rvm/bin]

I found a similar question on stackoverflow sudo: ruby: command not found after ssh

As user terdon explains it's caused by ruby not being in the sudo path. So I tried sudo-ing my type ruby but nothing happened. How do I fix this? Thanks in advance!

if this helps my type ruby is /home/user/.rvm/rubies/ruby-2.2.2/bin/ruby

and my echo path is

/home/user/.rvm/gems/ruby-2.2.2/bin:/home/user/.rvm/gems/ruby-2.2.2@global/bin:/home/user/.rvm/rubies/ruby-2.2.2/bin:/home/user/.rvm/bin:/usr/local/heroku/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
golymer
  • 11

2 Answers2

1

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"
0

Try reinstalling ruby maybe?

sudo apt-get install --reinstall ruby

Noki
  • 942