簡體   English   中英

使用 RVM 安裝 Ruby 時如何修復錯誤?

[英]How to fix error when installing Ruby using RVM?

我的操作系統是 macOS Catalina 10.15.7,我目前安裝了 ruby 2.6.3。

我嘗試使用 RVM 安裝 Ruby 但它給出了錯誤。

▶ rvm use ruby --install --default 
> Required ruby-3.0.0 is not installed 
> installing. ruby-3.0.0 - #removing src/ruby-3.0.0 - please
> wait Searching for binary rubies, this might take some time. No binary
> rubies available for: osx/10.15/x86_64/ruby-3.0.0. Continuing with
> compilation. Please read 'rvm help mount' to get more information on
> binary rubies. Checking requirements for osx. Certificates bundle
> '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
> Requirements installation successful. Installing Ruby from source to:
> /Users/soonersoft/.rvm/rubies/ruby-3.0.0, this may take a while
> depending on your cpu(s)... ruby-3.0.0 - #downloading ruby-3.0.0, this
> may take a while depending on your connection... ruby-3.0.0 -
> #extracting ruby-3.0.0 to /Users/soonersoft/.rvm/src/ruby-3.0.0 - please wait ruby-3.0.0 - #configuring - please wait Error running 'env
> CFLAGS=-O3 -I/usr/local/opt/libyaml/include
> -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include LDFLAGS=-L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib
> -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib ./configure --prefix=/Users/soonersoft/.rvm/rubies/ruby-3.0.0 --disable-install-doc --enable-shared', please read /Users/soonersoft/.rvm/log/1612806268_ruby-3.0.0/configure.log There
> has been an error while running configure. Halting the installation.
> Gemset '' does not exist, 'rvm ruby-3.0.0 do rvm gemset create '
> first, or append '--create'.

有沒有人遇到過同樣的錯誤? 如果是這樣,你是如何解決這個問題的?

要遵循的常見步驟如下:

ruby -v                         # To Check the current ruby version (if installed)
rvm install ruby-X.X.X          # To Install a specific ruby version
rvm list                        # To List the existing ruby versions                                    
rvm use ruby-X.X.X              # To Choose a version to use from the list ☝︎
rvm use ruby-X.X.X --default    # To Set a version as default

而且,正如@Tarek N. Elsamni 提到的:

rvm use ruby --install --default --create   # To create default gemset for Rails (visible in the last line of your error message)

您始終可以在安裝前后運行rvm list ,因為它可以讓您更好地了解您已安裝的所有 ruby 版本。

↳ Output 示例:

DRG@GALVEZWEB current_project % rvm list     

       ruby-2.6.6 [ x86_64 ]
       ruby-2.7.1 [ x86_64 ]
    =* ruby-3.0.0 [ x86_64 ]

    # => - current
    # =* - current && default
    #  * - default

您需要在命令中添加--create標志。 成為:

rvm use ruby --install --default --create

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM