在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
his one is tailor made for the Basix users among you. If you've been itching to try out Ruby and/or Rails, if the Terminal is somewhat new to you, you may find that even the process of installing it can generate countless confusing errors. This article will detail the exact steps you need to follow to get Ruby up and running on your Mac. Step 1 - RVMWhat you might be interested to know is that Ruby comes preinstalled on your Mac. Don't believe me? Open the Terminal and type:
Likely, the version number will return
These days, RVM is the way the cool kids install Ruby, and that's what we'll use.
Open the Terminal, and type:
Step 2 - Load RVM into the ShellGive that a few seconds to install, and next, we need to make RVM available to the shell. We'll do this by updating our
Note that we're using Vim to update this file, which can be a bit confusing at first. Feel free to open this file in any code editor your prefer. Maybe you want to use
If you're using Vim, you'll need to press Step 3 - Restart TerminalJust to be safe, let's restart Terminal to make sure that everything took effect. To ensure that RVM is correctly installed, type:
You should see a long list of commands that are available to you. Good job; that part is out of the way. Step 4 - Download the Latest Version of XcodeFrom my experiences, the biggest gotcha is when you try to install a new version of Ruby with RVM, and you're met with a handful of confusing errors. Most of the time, this is the result of Apple's Xcode not being installed on your system, or, if it is, not being the current version. You can download Xcode from Apple's App Store. Search for "xcode" and click the install button. You might want to fix yourself some lunch, as this large file will take some time to download. Once it does, though, run the install process, and, when finished, close Xcode. You shouldn't need to restart your computer, but, if it keeps you in the good graces of the church, go ahead and do so. Step 5 - Download Ruby 1.9.2Next, restart Terminal, and type:
You'll see a long list of versions...
For our needs, let's install Ruby 1.9.2
That shouldn't take but a moment.
Once the installation has completed, we need to tell RVM which version of Ruby we currently want to use:
Next, test it by checking the version number:
On my computer, this returns Step 6 - Make 1.9.2 the DefaultIf you restart Terminal, and type
This bit is identical to what we did just a moment ago - the only difference being that we've specified that 1.9.2 should be the default. Step 7 - Finished. Begin Installing GemsAnd that's it! You're all set to go! If you'd like to experiment with Ruby's syntax, type:
The next step is to install any gems that you require. For example, if you want to work with Ruby on Rails:
Or possibly Sinatra:
Important: Note that I'm not using
ConclusionIf this tutorial seemed incredibly easy to you, that's because it wasn't intended for you. Not everyone is comfortable with the command line, and not everyone installs Ruby without first being met with a huge crop of errors. Hopefully, this article will help a bit. And, again, if you're still having trouble, leave a comment, and we'll do our best to help you out! Alternatively to RVM, you also might look into rbenv, which, though quite new, is quickly gaining popularity.
安装命令 -> sudo gem install cocoapods墙挡了.出这个错 ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://api.rubygems.org/quick/Marshal.4.8/cocoapods-0.39.0.gemspec.rz)
这是因为ruby的软件源rubygems.org因为使用亚马逊的云服务,还是墙..,需要更新一下ruby的源,过程如下: Could not find a valid gem 'cocoapods' (>= 0) in any repository
$ gem sources -l (查看当前ruby的源)
查看当前ruby的软件源 cuiwenlongdeMac-mini:~ cuiwenlong$ gem sources -l *** CURRENT SOURCES *** https://gems.ruby-china.org/
加进ruby源之后,就再次安装,成功了 cuiwenlongdeMac-mini:~ cuiwenlong$ sudo gem install cocoapods Password: Fetching: nap-1.0.0.gem (100%) Successfully installed nap-1.0.0 Fetching: thread_safe-0.3.5.gem (100%) Successfully installed thread_safe-0.3.5 Fetching: minitest-5.8.3.gem (100%) Successfully installed minitest-5.8.3 Fetching: tzinfo-1.2 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论