Most of the time, gems in Ruby Just Work. But when you do, Google is surprisingly unhelpful. The error messages are generic, so they could have one of many different causes. Gems might seem magical. A Ruby gem is just some code zipped up with a little extra data. You can see the code inside a gem with gem unpack :. It grabs the gem and puts its files into a special directory on your system.
These paths vary from system to system, and they also depend on how you installed Ruby rvm is different from Homebrew, which is different from rbenv, and so on. The comment is pretty clear:.
That gives you this error:. You can even use the original version of require , the one that was overwritten by RubyGems:. RubyGems might seem complicated. But knowing RubyGems even at this surface level will help out a lot. You can understand where your gems live, so you can make sure that RubyGems knows about them.
And once you know how gems are loaded, you can dig into some crazy-looking loading problems. Have you slogged through the same guide three times and still don't know how to build a real app?
Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search. I can finds gems that are installed using gem list , but it doesn't show me where the gems are installed. How can I find where the gems are, and how can I know before installing a gem where it will be installed? Use gem environment to find out about your gem environment:. You will be able to see the list of gems you have installed.
Now use bundle show and name the gem you want to know the path for, like this:. To complete other answers, the gem-path gem can find the installation path of a particular gem. You can check it from your command prompt by running gem help commands and then selecting the proper command:. The gem env lists where gems can be installed, but this can be 10 or more locations. If you want to know where a particular gem is installed, you can execute:.
This works and gives you the installed at path for each gem. This super helpful when trying to do multi-stage docker builds.. You can copy in the specific directory post-bundle install. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to find where gem files are installed Ask Question. Asked 8 years, 1 month ago. Active 2 months ago.
Viewed k times. Improve this question. Add a comment. Active Oldest Votes. Improve this answer. Hrishikesh Kadam Thanks for your info! Is that right? Rustam A. Gasanov Rustam A. Gasanov 14k 8 8 gold badges 54 54 silver badges 72 72 bronze badges. This is a very nice simple method that doesn't require bundler although I do love bundler I like this version because its useful for people doing logstash development no bundler on my servers.
0コメント