programing

Gem 파일이 설치된 위치를 찾는 방법

javamemo 2023. 6. 4. 10:13
반응형

Gem 파일이 설치된 위치를 찾는 방법

다음을 사용하여 설치된 보석을 찾을 수 있습니다.gem list보석이 어디에 설치되어 있는지는 표시되지 않습니다.

보석을 설치하기 전에 보석이 어디에 있는지 어떻게 알 수 있습니까?

사용자의 보석 환경에 대해 알아봅니다.

RubyGems Environment:
  - RUBYGEMS VERSION: 2.1.5
  - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin12.4.0]
  - INSTALLATION DIRECTORY: /Users/ttm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: /Users/ttm/.rbenv/versions/2.0.0-p247/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/ttm/.rbenv/versions/2.0.0-p247/bin
  - SPEC CACHE DIRECTORY: /Users/ttm/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /Users/ttm/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0
     - /Users/ttm/.gem/ruby/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/ttm/.rbenv/versions/2.0.0-p247/bin
     - /Users/ttm/.rbenv/libexec
     - /Users/ttm/.rbenv/plugins/ruby-build/bin
     - /Users/ttm/perl5/perlbrew/bin
     - /Users/ttm/perl5/perlbrew/perls/perl-5.18.1/bin
     - /Users/ttm/.pyenv/shims
     - /Users/ttm/.pyenv/bin
     - /Users/ttm/.rbenv/shims
     - /Users/ttm/.rbenv/bin
     - /Users/ttm/bin
     - /usr/local/mysql-5.6.12-osx10.7-x86_64/bin
     - /Users/ttm/libsmi/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/bin

다음 두 섹션에 유의하십시오.

  • INSTALLATION DIRECTORY
  • GEM PATHS

다음을 사용하여 라이브러리 파일의 위치를 가져오는 것이 유용하다는 것을 알게 되었습니다.

gem which *gemname*

보석을 설치한 후 특정 보석이 어디에 있는지 알고 싶다면,입력해 보십시오.

 gem list

설치한 보석 목록을 볼 수 있습니다.지금 사용bundle show경로를 알고 싶은 보석의 이름을 대보세요.

 bundle show <gemName>

또는 (이전 버전의 번들러 기준):

 bundle info <gemName>

다른 답변을 완료하기 위해 보석 경로 보석은 특정 보석의 설치 경로를 찾을 수 있습니다.

설치:

gem install gem-path

용도:

gem path rails
=> /home/cbliard/.rvm/gems/ruby-2.1.5/gems/rails-4.0.13
gem path rails '< 4'
=> /home/cbliard/.rvm/gems/ruby-2.1.5/gems/rails-3.2.21

이 기능은 파일을 grep 또는 편집하는 데 사용할 수 있으므로 매우 유용합니다.

grep -R 'Internal server error' "$(gem path thin)"
subl "$(gem path thin)"

를 실행하여 명령 프롬프트에서 확인할 수 있습니다.gem help commands적절한 명령을 선택합니다.

kirti@kirti-Aspire-5733Z:~$  gem help commands
GEM commands are:

    build                  Build a gem from a gemspec
    cert                   Manage RubyGems certificates and signing settings
    check                  Check a gem repository for added or missing files
    cleanup                Clean up old versions of installed gems in the local
                           repository
    contents               Display the contents of the installed gems
    dependency             Show the dependencies of an installed gem
    environment            Display information about the RubyGems environment
    fetch                  Download a gem and place it in the current directory
    generate_index         Generates the index files for a gem server directory
    help                   Provide help on the 'gem' command
    install                Install a gem into the local repository
    list                   Display gems whose name starts with STRING
    lock                   Generate a lockdown list of gems
    mirror                 Mirror all gem files (requires rubygems-mirror)
    outdated               Display all gems that need updates
    owner                  Manage gem owners on RubyGems.org.
    pristine               Restores installed gems to pristine condition from
                           files located in the gem cache
    push                   Push a gem up to RubyGems.org
    query                  Query gem information in local or remote repositories
    rdoc                   Generates RDoc for pre-installed gems
    regenerate_binstubs    Re run generation of executable wrappers for gems.
    search                 Display all gems whose name contains STRING
    server                 Documentation and gem repository HTTP server
    sources                Manage the sources and cache file RubyGems uses to
                           search for gems
    specification          Display gem specification (in yaml)
    stale                  List gems along with access times
    uninstall              Uninstall gems from the local repository
    unpack                 Unpack an installed gem to the current directory
    update                 Update installed gems to the latest version
    which                  Find the location of a library file you can require
    yank                   Remove a specific gem version release from
                           RubyGems.org

For help on a particular command, use 'gem help COMMAND'.

Commands may be abbreviated, so long as they are unambiguous.
e.g. 'gem i rake' is short for 'gem install rake'.
kirti@kirti-Aspire-5733Z:~$ 

이제 위에서 명령을 볼 수 있습니다.environment도움이 됩니다.그래서 저는 할 것입니다.

kirti@kirti-Aspire-5733Z:~$ gem help environment
Usage: gem environment [arg] [options]


  Common Options:
    -h, --help                       Get help on this command
    -V, --[no-]verbose               Set the verbose level of output
    -q, --quiet                      Silence commands
        --config-file FILE           Use this config file instead of default
        --backtrace                  Show stack backtrace on errors
        --debug                      Turn on Ruby debugging


  Arguments:
    packageversion  display the package version
    gemdir          display the path where gems are installed
    gempath         display path used to search for gems
    version         display the gem format version
    remotesources   display the remote gem servers
    platform        display the supported gem platforms
    <omitted>       display everything

  Summary:
    Display information about the RubyGems environment

  Description:
    The RubyGems environment can be controlled through command line arguments,
    gemrc files, environment variables and built-in defaults.

    Command line argument defaults and some RubyGems defaults can be set in a
    ~/.gemrc file for individual users and a /etc/gemrc for all users. These
    files are YAML files with the following YAML keys:

      :sources: A YAML array of remote gem repositories to install gems from
      :verbose: Verbosity of the gem command. false, true, and :really are the
                levels
      :update_sources: Enable/disable automatic updating of repository metadata
      :backtrace: Print backtrace when RubyGems encounters an error
      :gempath: The paths in which to look for gems
      :disable_default_gem_server: Force specification of gem server host on
    push
      <gem_command>: A string containing arguments for the specified gem command

    Example:

      :verbose: false
      install: --no-wrappers
      update: --no-wrappers
      :disable_default_gem_server: true

    RubyGems' default local repository can be overridden with the GEM_PATH and
    GEM_HOME environment variables. GEM_HOME sets the default repository to
    install into. GEM_PATH allows multiple local repositories to be searched for
    gems.

    If you are behind a proxy server, RubyGems uses the HTTP_PROXY,
    HTTP_PROXY_USER and HTTP_PROXY_PASS environment variables to discover the
    proxy server.

    If you would like to push gems to a private gem server the RUBYGEMS_HOST
    environment variable can be set to the URI for that server.

    If you are packaging RubyGems all of RubyGems' defaults are in
    lib/rubygems/defaults.rb.  You may override these in
    lib/rubygems/defaults/operating_system.rb
kirti@kirti-Aspire-5733Z:~$ 

마지막으로 질문하신 내용을 보여드리겠습니다.

kirti@kirti-Aspire-5733Z:~$ gem environment gemdir
/home/kirti/.rvm/gems/ruby-2.0.0-p0
kirti@kirti-Aspire-5733Z:~$ gem environment gempath
/home/kirti/.rvm/gems/ruby-2.0.0-p0:/home/kirti/.rvm/gems/ruby-2.0.0-p0@global
kirti@kirti-Aspire-5733Z:~$ 

속일 수 있습니다gem open보석 경로를 표시합니다.

VISUAL=echo gem open gem-name

예:

VISUAL=echo gem open rails
=> /usr/local/opt/asdf/installs/ruby/2.4.3/lib/ruby/gems/2.4.0/gems/rails-5.1.4

그것은 단지 효과가 있을 뿐이며, 제3자 보석은 필요하지 않습니다.

gem env와 똑같이 작동합니다.gem environment타이핑을 저장합니다.

# gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.14
  - RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [i686-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.0.0
     - /root/.gem/ruby/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

gem env에는 보석을 설치할 수 있는 위치가 나열되어 있지만 이 위치는 10개 이상일 수 있습니다.특정 보석이 설치된 위치를 알고 싶다면 다음을 실행할 수 있습니다.

gem list -d <gemname>

출력 예:

tilt (2.0.9)
    Author: Ryan Tomayko
    Homepage: http://github.com/rtomayko/tilt/
    License: MIT
    Installed at: /opt/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0

    Generic interface to multiple Ruby template engines

rvm 도구를 사용하는 경우 다음 명령을 실행하여 gem 경로를 인쇄할 수 있습니다.

rvm gemdir

OR

echo $GEM_HOME

이것은 작동하며 각 보석의 경로에 설치된 를 제공합니다.이는 다단계 도커 빌드를 시도할 때 매우 유용합니다.특정 디렉토리에서 번들 후 설치를 복사할 수 있습니다.

bash-4.4# gem list -d

출력:

aasm (5.0.6)
    Authors: Thorsten Boettger, Anil Maurya
    Homepage: https://github.com/aasm/aasm
    License: MIT
    Installed at: /usr/local/bundle

  State machine mixin for Ruby objects

갈 수 있습니다rails console그리고 합니다.

Gem.bin_path('<gem-name>', '<gem-executable-name>')

Gem 파일 실행 파일의 정확한 경로를 반환합니다.

참조: https://www.rubydoc.info/github/rubygems/rubygems/Gem.bin_path

gem info YourTargetName

예:

gem info cocoapods-packager


*** LOCAL GEMS ***

cocoapods-packager (1.5.0)
    Authors: Kyle Fuller, Boris Bügling
    Homepage: https://github.com/CocoaPods/cocoapods-packager
    License: MIT
    Installed at: /Users/localName/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0

CocoaPods plugin which allows you to generate a framework or static
library from a podspec.

언급URL : https://stackoverflow.com/questions/19072070/how-to-find-where-gem-files-are-installed

반응형