Programing

Homebrew를 사용하여 설치된 루비 1.9.3으로 어떻게 전환 할 수 있습니까?

lottogame 2020. 10. 16. 07:00
반응형

Homebrew를 사용하여 설치된 루비 1.9.3으로 어떻게 전환 할 수 있습니까?


내가 사용 1.9.3 루비 설치 한 hombrew을

양조 루비 설치

그러나 기본 1.8.7이 계속 사용됩니다. 1.9.3을 기본 루비로 사용하도록 osx를 어떻게 전환 할 수 있습니까?


rvm 살펴보기를 제안합니다 . 그런 다음 다음을 사용하여 기본값으로 설정할 수 있습니다.rvm use 1.9.3 --default

그러나 홈브류 설치에 만족한다면.

그런 다음 디렉토리의 우선 순위를 PATH

여기에 내 / etc / paths가 있습니다.

# homebrews should always take precedence
/usr/local/bin

# the default stack
/usr/bin
/bin
/usr/sbin
/sbin

이것은 일반적으로 homebrew에 중요합니다. 그렇지 않으면 brew 버전 대신 git, ruby, pg_admin, ...의 시스템 버전이 모두 사용됩니다.

which -a ruby설치된 모든 루비를 볼 수 있다고 말하면PATH

예.

$ which -a ruby
/Users/matthew/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
/Users/matthew/.rvm/bin/ruby
/usr/bin/ruby


업데이트 : 이제 변경해야한다고 생각하지 않습니다. /etc/paths

대신 당신은 어떤 확인해야합니다 .profile, .bashrc또는 .bash_login쉘에로드되고, 그냥 추가 /usr/local/bin경로에.

저에게는 .profile. 홈 디렉토리에 이미 존재하는 파일이없는 경우 해당 파일을 만들 수 있습니다.

# homebrews should always take precedence
export PATH=/usr/local/bin:$PATH

짧은 답변:

homebrew를 통해 루비를 설치 한 후 다음을 수행하십시오.

brew link --overwrite ruby

터미널을 다시 시작하거나 다시 엽니 다.  


긴 답변

그래서 homebrew를 사용하여 루비를 정상적으로 설치했습니다.

brew install ruby

잘 설치되었지만 여전히 시스템의 기본 루비를 사용하고있었습니다. 나는 다음을 수행하여 확인했습니다.

which ruby 
#/usr/bin/ruby

그래서 Matthew Rudy의 제안에 따라 / etc / paths의 순서를 확인했고 모두 좋았습니다.

그런 다음 결정했습니다.

which -a ruby
#/usr/bin/ruby
#usr/local/bin/ruby

그래서 아무것도 깨지지 않았습니다. homebrew 방법을 사용하여 루비를 다시 설치하려고 시도한 후 찾았습니다.

Homebrew는 다음과 같이 언급했습니다.

Warning: ruby-2.3.1 already installed, it's just not linked

그래서해야했다 :

brew link --overwrite ruby

If you'd like to use homebrew to install 1.9.3, you can follow these steps:

$ brew update
$ brew install rbenv
$ brew install ruby-build

Once you have rbenv and ruby-build installed, you can run the following command to get Ruby 1.9.3 installed.

$ rbenv install 1.9.3-p125

Now if you’d like to use 1.9.3 by default, you can run the following command:

$ rbenv global 1.9.3-p125

I had similar situation. I installed ruby using Homebrew. which -a ruby gave me the following output:

#usr/local/bin/ruby
#/usr/bin/ruby

Which means that newly installed version should have been used, but ruby --version still returned the old system version.

I quit terminal (Cmd+Q), and after restart ruby --version returned the correct version. So make sure you restart terminal after installing before trying any other (potentially unnecessary) fixes.


SHORT: Do note what you want to change it for.

If you're on OS X and trying to use Ruby for something like Jekyll, then don't use homebrew because that's what Apple is using for Ruby for and it might not be good to use if you're not sure what you're doing. Instead, use rbenv or RVM.

LESS SHORT: I was trying to switch from the default version to an updated version (from 2.0) to use Jekyll because it required Ruby version 2.2.5 and above. I updated it and version 2.5 was installed, but when I checked "ruby -v", it was still 2.0. Once I finally got around to changing the default version, I wasn't able to install the package I needed because I didn't have write permission. For example, if you come across something like this, then you probably are having the same problem

$ gem install jekyll bundler
ERROR:  While executing gem ... (Gem::FilePermissionError)    
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

In OSX you can change the path using:

sudo nano /etc/paths

And then add a path or change the order.


Just as an alternative approach for anyone else looking for an answer to this - you can set an alias in your .bash_profile e.g

ruby="/usr/local/bin/ruby"

this is how i got around the issue

참고URL : https://stackoverflow.com/questions/8730676/how-can-i-switch-to-ruby-1-9-3-installed-using-homebrew

반응형