You are viewing the article How to Execute Ruby Code at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This wikiHow teaches you how to execute Ruby code on Windows, macOS, Ubuntu, and Debian Linux. To run a Ruby program, the Ruby software must be pre-installed on the computer. Although macOS and most Linux distributions come with Ruby pre-installed, you need to check to make sure the current version is the latest before proceeding with the program. Also, if the Ruby code to deploy is written by you in a text editor or developer environment, save it as a .rb file so you can execute it from the command line.
Steps
On macOS
- Click the Launchpad icon in the Dock (multicolored squares).
- Type terminal in the search field.
- Click the Terminal icon.
- If you don’t have the Homebrew program, you need to type /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" and press Return to install Homebrew. [1] X Research Source
- Type brew install ruby and press Return .
- Type open -e ~/.zshrc then press Return to open the shell configuration file in TextEdit. [2] X Research Source
- Add the following lines to the end of the file if your Mac uses an Intel-based chip:
- if [ -d "/usr/local/opt/ruby/bin" ]; then
- export PATH=/usr/local/opt/ruby/bin:$PATH
- export PATH=`gem environment gemdir`/bin:$PATH
- fi
- Add the following lines to the end of the file if your Mac uses an Apple silicon chip:
- if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
- export PATH=/opt/homebrew/opt/ruby/bin:$PATH
- export PATH=`gem environment gemdir`/bin:$PATH
- fi
- Save and close the file.
- Close and reopen the Terminal window.
- Enter the command brew pin ruby then press Return .
- You can see the list of files in the current directory by typing ls -a and then pressing Return .
On Windows
- If you’re not sure which version to download, look in the right column on the installer’s website for recommended options. [3] X Research Sources
- During the installation process, keep the default settings (unless you know what you need to change). The default settings will add the Ruby directory to the system path so that you can execute ruby code from the command prompt.
- You can also click the Search bar (or magnifying glass icon) next to the Start button, type Command , and then click Start Command Prompt With Ruby from within the search results.
Debian and Fedora Linux
- Type sudo apt-get update and then press Enter to update the package list.
- Type sudo apt-get install ruby-full and press Enter to install the latest version of Ruby.
- Type ls -a and then press Enter to view the files in the current directory.
This article is co-authored by a team of editors and trained researchers who confirm the accuracy and completeness of the article.
The wikiHow Content Management team carefully monitors the work of editors to ensure that every article is up to a high standard of quality.
This wikiHow teaches you how to execute Ruby code on Windows, macOS, Ubuntu, and Debian Linux. To run a Ruby program, the Ruby software must be pre-installed on the computer. Although macOS and most Linux distributions come with Ruby pre-installed, you need to check to make sure the current version is the latest before proceeding with the program. Also, if the Ruby code to deploy is written by you in a text editor or developer environment, save it as a .rb file so you can execute it from the command line.
Thank you for reading this post How to Execute Ruby Code at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.
Related Search: