Home > Mobile >  How do I run a ruby file in vscode terminal?
How do I run a ruby file in vscode terminal?

Time:11-16

So here is my problem. I have a folder with a lib and spec folder inside. I am trying to access a file inside my lib, named part_1.rb, and run it but I don't know how to.

My code: (asterisk used to cover ubuntu name)

 *****:~$ ruby part_1.rb
 ruby: No such file or directory --part_1.rb (LoadError)

CodePudding user response:

try using: chmod x part_1.rb and then execute via ./part_1.rb

CodePudding user response:

To check that the file is in your current directory, run ls. This will print the contents of your current directory.

If the file is not in your current directory, but in your lib directory, you have two choices to run the file.

This will change your directory, then run the file.

cd lib
Ruby part_1.rb

This will search for the file in the subdirectory.

Ruby lib/part_1.rb
  • Related