Which ruby to install
See the ruby RubyInstaller versions 2. Please note, that some gems are not yet compatible with Ruby You should therefore stay on 2. Homebrew is using the absolute location to reliably call the Ruby command on a machine with unknown configuration. I also notice that the Ruby command is getting called with the -e flag.
If we type man ruby into our terminal, we can explore the documentation and find out what the -e flag does. To understand what that documentation means, you need to understand that the typical usage of the Ruby command would be to pass an executable Ruby file to it.
The -e command lets the Ruby CLI know that you want to treat whatever comes after the flag as the script to execute instead of looking for a file. We can test this out on our own by running an inline Ruby program! The command is also using several flags.
Again, we can use the man command and pass curl to it…which, while being slightly funny, is also super useful and can help us find out what these flags are doing. That was pretty straightforward. In Bash, the best way to do string interpolation is to call a command from within a set of parenthesis preceded by a dollar sign.
What I hope you take away from this section is that taking the time to understand some of the extra stuff is important and that the man command is your friend. Alright, so now that Homebrew is installed, we can use it to install a newer version of Ruby. The command is pretty straightforward:.
With this, Homebrew will go out and fetch not only Ruby but also any dependencies Ruby needs to run. What gives? Homebrew was nice enough to tell us what happened. Here is a snippet of the output from the brew install ruby command:. Remember earlier when I mentioned that package managers like Homebrew keep our machine tidy by installing things in a consistent manner?
This output relates to that bit of information. When Homebrew installs a package, it will actually install it in a directory that Homebrew owns. A symlink, or symbolic link, is a special type of file that acts as a redirect to where the actual file lives. This allows Homebrew to be selective about what executables it makes available.
It tells us how to fix this situation by modifying our PATH. If Ruby is installed, the which command may show the Ruby version number in the file path:. You may want to know more than the Ruby version number.
You may want to know how Ruby is installed and where Ruby is installed. The which command will show you. You can use the which command with the -a flag to see if more than one Ruby executable is installed and where they are installed:. Homebrew is a package manager that adds languages or software packages to the Mac.
It can install one and only one! The version of Ruby installed by Homebrew is primarily intended for use by other Homebrew packages. As such, it can be updated to a newer version without warning when Homebrew updates the dependencies of other packages. However, note that Rails is generally used to develop database-backed web applications. That means that it needs a database server to talk to.
It stores its data in a file on disk. So you may want to install one of those on your Windows machine and then generate your Rails app with the option to specify that database driver.
Prefix works with. As mentioned previously, with Windows 10, Microsoft started offering a standard way to run a Linux command line on Windows computers. It is also a good way to get working with Ruby on Windows. You even get your choice of Linux distro. To use the WSL, you first need to enable it. There are tutorials online that tell you how to do this by running a command in an admin console e.
After your computer has rebooted, you can install the Linux distro of your choice from the Microsoft Store. Your spiffy new Ubuntu command line will be available as an app from the Windows menu:. Running that opens a terminal window and kicks off the setup steps for this mini Linux install. There are only two steps: enter a username and a password.
They can be the same as your Windows username and password or different. After setting that up, you should have a working Bash prompt! There are lots of tutorials online about how to use the Linux command line.
From here on, you could probably follow any tutorial on installing Ruby on Ubuntu. Read on for specific steps to Ruby joy. The easiest way to install Ruby on Ubuntu is with a package manager. Run the following in your Bash terminal:.
0コメント