回答
使用gem environment
,瞭解你的寶石環境:
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 help commands
,然後選擇合適的命令從命令提示符檢查:
[email protected]:~$ 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'.
[email protected]:~$
現在從上面可以看我的命令environment
是很有幫助的。所以,我會做:
[email protected]:~$ 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
[email protected]:~$
最後向你展示你的要求,我會做:
[email protected]:~$ gem environment gemdir
/home/kirti/.rvm/gems/ruby-2.0.0-p0
[email protected]:~$ gem environment gempath
/home/kirti/.rvm/gems/ruby-2.0.0-p0:/home/kirti/.rvm/gems/[email protected]
[email protected]:~$
謝謝!我不知道'gem help命令'。我應該寫我正在使用rbenv。 – ironsand
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 list
您將能夠看到已安裝的寶石列表。現在使用bundle show
和名字,你想知道該路徑的寶石,如:
bundle show <gemName>
我不確定這是否適用於所有目錄。我運行這個命令並得到'找不到Gemfile或.bundle /目錄。 –
這是最好的方式,因爲它顯示完整路徑,(而'gem env')只顯示'gems'文件夾的父文件夾:'/home/test/.rbenv/versions/2.5.0/lib/ruby/寶石/ 2.5.0'。裏面有很多文件夾,你的寶石可能位於幾乎任何一個文件夾中 - 這就是'bundle show
要完成其他的答案中,gem-path寶石可以找到一個特定的寶石的安裝路徑。
安裝:
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*
這是一個非常好的簡單方法,不需要捆綁器(儘管我喜歡捆綁器:-)。 – antinome
這是我認爲最有用的答案,謝謝! – jmm
最簡單的答案,不需要導軌或捆綁器!好一個! – lacostenycoder
在MAC OS,屬於寶石Ruby文件存在於
/Library/Ruby/Gems/<Ruby_Version>/gems
目錄。
您可以通過使用命令獲得對應於寶石的文件的位置:
gem contents <gem_name>
我想這RVM(和rbenv)保存路徑寶石的家變成一個環境變量。如果我運行
env | grep GEM_
我得到
- GEM_HOME=/Users/Me/.rvm/gems/[email protected]_project
- GEM_PATH = /用戶/ ME/.rvm/gems/[email protected]_project:/Users/Me/.rvm/gems/[email protected]_project
我認爲$ GEM_HOME是你有興趣
的位置G EMS將被安裝到$ GEM_HOME 「/寶石」
你就可以欺騙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
- 1. Gem文件中的Gem安裝配置
- 2. 無法找到設置Django安裝位置的文件
- 3. 我如何在Linux中找到安裝的軟件的位置?
- 4. 如何通過HTTP安裝gem文件?
- 5. 如何重定向gem文件安裝
- 6. Rails使用gem後找到已安裝的.html.erb文件
- 7. 安裝matlab 2013a找到許可證文件的位置
- 8. 如何找到使用批處理文件安裝Windows的位置
- 9. pg gem安裝失敗,無法找到libpq-fe.h頭文件
- 10. 服務器在安裝了will_paginate gem後找不到文件'will_paginate'
- 11. 如何找到apc.php文件的位置?
- 12. 安裝gem時無法找到libxml2
- 13. 如何找到安裝在Windows上的熊貓的位置
- 14. 從安裝位置將文件複製到安裝目錄
- 15. Ruby Gem:將配置文件安裝到用戶主目錄
- 16. 如何將gem安裝到當前文件夾
- 17. 如何找到安裝Ruby Gem的路徑(即Gem.lib_path c.f. Gem.bin_path)
- 18. 如何在安裝完成後找到安裝文件夾?
- 19. 如何找到服務的安裝位置? C#
- 20. 如何找到Grails/Groovy在Mac上安裝的位置?
- 21. 如何找到流星安裝在窗戶的位置?
- 22. 如何找到Mac OS上的memcached安裝位置?
- 23. 無法安裝mysql2 gem。安裝找不到mysql.h中
- 24. 安裝Xampp後無法找到PHP安裝位置
- 25. 寶石安裝如何工作? gem如何獲得安裝文件?
- 26. 定義安裝文件的位置
- 27. 如何找到通過egg-link安裝的python軟件包的位置?
- 28. 當我剛安裝Gem時找不到Gem
- 29. Capistrano從git rails安裝gem沒有找到gem?
- 30. 如何設置Jenkins安裝文件位置?
感謝您的信息!在我的環境中,似乎'GEM PATHS'只用於第一個。是對的嗎? – ironsand
'gem env'簡稱 – zanderwar