Setting up a Ruby dev environment

Hi there. I’m an absolute beginner to Ruby, and I’m trying to set up my own Ruby dev environment so I can practise outside of just using the exercises on the Codecademy tutorials. How is best to do this? I’m having some trouble. I know I can download a text editor and write the code…then how do I test it?

Trying to look up instructions on the internet but everything I’ve found so far doesn’t seem to be aimed at an absolute beginner!

I don’t know what operating system you use.

If you use Linux, for example Fedora - you just need to open up terminal and use package manager to install ruby. In Fedora you would use dnf and this command:

sudo dnf install ruby ruby-devel

Now you just need to write script in your favorite code editor (I like vim) and then in the terminal move to directory where your script is and execute command:

ruby nameOfTheScriptFile.rb

That’s all! :slight_smile:

On Windows everything is more complicated, as always. The best choice is to use 3rd party software - RubyInstaller.

After installation create a new file with .rb extension and put there some ruby code. Now, open cmd or PowerShell, move (using cd command) to the directory where your script file is saved. And run your program using command:

ruby nameOfTheScriptFile.rb

If you see an error saying that ruby is not recognized as an internal or external command you have to add folder with ruby binaries to the environment variable path. If this happens - post here name and version of your operating system and I will write a quick tutorial.

If there is something unclear, or you don’t know how to open cmd or terminal, just let me know and I will try to create more specific instructions.

1 Like