我可以找到宝石安装使用宝石列表,但它不告诉我宝石安装在哪里。
我如何才能找到宝石的位置,我如何才能在安装宝石之前知道它将被安装在哪里?
我可以找到宝石安装使用宝石列表,但它不告诉我宝石安装在哪里。
我如何才能找到宝石的位置,我如何才能在安装宝石之前知道它将被安装在哪里?
当前回答
你可以欺骗gem open显示gem路径:
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
它只是工作,没有第三方宝石是必要的。
其他回答
宝石环境工作就像宝石环境。节省一些输入。
# 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-path gem可以找到特定gem的安装路径。
安装:
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 which *gemname*
如果你正在使用RVM工具,你可以运行这个命令打印gem路径:
rvm gemdir
OR
echo $GEM_HOME
使用gem环境来了解您的gem环境:
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
请注意以下两部分:
安装目录 宝石路