Nice programing

번 들러를 사용하여 gem을 다시 설치하는 방법

nicepro 2020. 12. 28. 22:33
반응형

번 들러를 사용하여 gem을 다시 설치하는 방법


나는했고 bundle showgem 디렉토리의 완전한 경로를 얻었습니다.

불행히도 rm -r gem_path. 그런 다음 내 레일 앱이 더 이상 작동하지 않습니다. 서버를 시작하거나 rails 콘솔을 시작하면 다음 오류가 출력됩니다.

<class:Application>: 초기화되지 않은 상수 MyAPP::Application::Gem(NameError)

다시 되돌리려면 어떻게해야합니까?

나는 시도 bundle install하거나 bundle update보석을 검색하고 다시 설치하는 번들을 강제 희망하지만, 작동하지 않았다.

나는 또한 삭제 시도 Gemfile.lock및 실행 bundle install. 변경된 것은없고 동일한 오류입니다.

문제의 gem은 Act as taggable on 입니다.


rbenv를 사용하는 경우 rmagick와 같은 gem을 완전히 제거하고 다시 설치할 수 있습니다.

첫째 : 간단한 제거 / 재설치 시도

gem uninstall rmagick
bundle install

그래도 작동하지 않으면 설치된 gem의 모든 흔적을 제거 할 수 있습니다. gem 설치 위치 찾기 :

bundle show rmagick
BUNDLE_DIR=$(dirname $(dirname $(bundle show rmagick)))
echo $BUNDLE_DIR

gem 설치 접두사는 기본 예 ~/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0또는 예를 들어 설정 한 것입니다..vendor

gem 디렉토리를 지 웁니다.

rm -rf $BUNDLE_DIR/gems/rmagick-*

컴파일 된 gem 캐시를 지 웁니다.

rm $BUNDLE_DIR/cache/rmagick*.gem

번 들러의 사양 캐시도 지 웁니다.

rm $BUNDLE_DIR/specifications/rmagick*gemspec

그런 다음 다시 설치할 수 있습니다.

bundle install

항상 다음을 사용할 수 있습니다.

gem pristine acts-as-taggable-on

pristine-설치된 gem을 gem 캐시에있는 파일에서 원래 상태로 복원합니다.

현재 프로젝트의 gem 만 복원하려면 다음을 실행해야합니다.

bundle exec gem pristine acts-as-taggable-on


우선은 한 gem q --L에 대한 바로 가기를 gem query --local. 설치된 모든 로컬 gem을 출력합니다.

actionmailer (3.2.8, 3.2.6, 3.2.1, 3.1.0)
actionpack (3.2.8, 3.2.6, 3.2.1, 3.1.0)
activemodel (3.2.8, 3.2.6, 3.2.1, 3.1.0)
activerecord (3.2.8, 3.2.6, 3.2.1, 3.1.0)
activeresource (3.2.8, 3.2.6, 3.2.1, 3.1.0)
activesupport (3.2.8, 3.2.6, 3.2.1, 3.1.0)
acts-as-taggable-on (2.3.3)
...

그리고, DVG의 조언에 따라, 나는 그것의 올바른 이름을 사용하여 보석 제거 gem uninstall acts-as-taggable-on및 달렸다 bundle install. 그 후 나는 아무 문제없이 rails c또는 rails s다시 할 수 있었다 .


터미널의 프로젝트 디렉토리에서

gem uninstall gem_name 

에서 gem과 함께 RVM사용 하는 경우 gem을 다시 설치하지 않으면 ~/.rvm/작동합니다 bundle.

먼저 gem 소스를 삭제합니다.

bundle show $GEM
rm -rf $PATH_TO_GEM

컴파일 된 gem 캐시를 지 웁니다.

rm -rf ~/.rvm/gems/ruby-$RUBYVERSION[@$GEMSET]/cache/$GEM.gem

번 들러의 사양 캐시도 지 웁니다.

rm -rf ~/.rvm/gems/ruby-$RUBYVERSION[@$GEMSET]/specifications/$GEM*gemspec

그런 다음 다시 설치할 수 있습니다.

bundle install

./bundle/vendor또는 유사하게 설치 한 경우 먼저 gem을 제거해야하지만 명시 적으로 GEM_HOME을 지정해야합니다. 예 :

GEM_HOME=./vendor/bundle/ruby/2.3.0/ gem uninstall rmagick

이는 번 들러를 사용하여 설치된 gem을 공급 업체 디렉토리에 제거하는 가장 간단한 방법입니다. 이상적으로는 명령 bundle uninstall또는 bundle reinstall이 있습니다 .

단순히 재설치하는 것이 목표 인 경우 다음 명령이 도움이 될 것입니다.

GEM_HOME=./vendor/bundle/ruby/2.3.0/ gem uninstall rmagick && sudo -u http bundle install

당신이 저와 같고 디렉토리 (예 :) 아래에 여러 웹 응용 프로그램이있는 /srv/http경우 다음은 모든 디렉토리에서 수행합니다.

cd /srv/http
for d in ./*/ ; do (cd "$d" && sudo -u http GEM_HOME=./vendor/bundle/ruby/2.4.0/ gem uninstall --force rmagick && sudo -u http bundle install); done

bundle exec gem uninstall <gem_name> - uninstalls gem from the bundle (the <app_root>/vendor/bundle/ruby/2.3.0/gems/ path). This is equivalent to the answer @ioquatix gave, but is the slightly more convenient solution that he was looking for.

gem uninstall <gem_name> - uninstalls gem only from the global gemset in the system


If you're trying to reinstall rake, gem pristine rake will fail with Skipped rake-10.X.X, it is a default gem and bundle won't install it either, because it can't uninstall it.

If you're using rvm, it seems the easiest was is simply to do a rvm reinstall 2.x.x. At least for me, rvm repair all also didn't help.

The same probably goes for all other default gems. I'll just list them here so that the desperate googlers find some help:

  • bigdecimal
  • drip
  • io-console
  • json
  • minitest
  • psych
  • rake
  • rbtree
  • rdoc
  • test-unit

ReferenceURL : https://stackoverflow.com/questions/12188833/how-to-reinstall-a-gem-using-bundler

반응형