When I download something using gem I'd like to be able to just download the gem, and then choose whether or not I want to install it. I'm asking this because I'd like to install a particular gem on more than one computers ( without installing from the internet on each one ).
gem fetch
So, something like $ gem fetch gosu ... this will leave gosu-0.7.14.gem in the current directory.
This will work even if you have already installed it.
Most of the gems are hosted on github.com right now, you just have to clone the repo.
Yes it is. Browse to the package's page on RubyGems.org and follow the download link.
Eg. from https://rubygems.org/gems/pony to https://rubygems.org/downloads/pony-1.4.gem
Related
I am patching a script, and want to run code from a repo I manage that has patches.
The gem in question is not installed through a published gem but through a github link
When requiring any gem that is normally installed. The script works. But requiring any gem that is installed through a github link fails. Any suggestions?
If I understand the problem correctly, there are a few solutions:
Clone the gem that's only available via the github link, build the gem locally, install it. You should be able to require it
You might be able to manage the project with bundler and a Gemfile. Instructions here for the syntax. Bundler basically does what I suggested above, for you. I don't think gem can install a gem from a remote natively?
Would love to see some more clarification, and if you're using a Gemfile the relevant snippets
So the issue was I was running the script in question using ./bin/path/script
This will not work if the script includes github referenced gems, you need to prefix this with bundle exec which is not immediately obvious, given that when you use non-github referenced gems, it works fine without it.
Now running bundle exec ./bin/path/script will work for both, it's probably just better using that wherever possible.
I am wondering, while I'm sifting through samples, how I locate the source library when installing gems. For example, I have
require 'oauth2'
and to install, I run
gem install oauth2
What repository is pulled from for gem installs? I want to use reflection to reverse engineer some of the calls in the samples.
By default gem pulls from Rubygems, the main gem repository, but you can install from anywhere if you give it a URL or use the --source option to specify an alternate source. Some prefer to use private gem hosting for their dependencies.
Why not use a Gemfile to manage your dependencies? It makes it a lot more clear:
source 'https://rubygems.org/'
gem 'oauth2'
Then you install:
bundle install
Then you can see where it got installed:
bundle show oauth2
From there you can look at the source. You can also look at the gem listing page for oauth2 where links to documentation and source are provided.
There are a few useful options for looking at source code for ruby gems.
As #tadman has mentioned you generally can expect the default gem source to be hosted at https://rubygems.org and using Bundler is also highly recommended.
In many cases the open source code will be hosted on https://github.com. I tend to prefer to fork the gem source and download my fork locally where I can analyze it in my editor without fear of accidentally breaking anything since your forked repo will contain the full git history/repo etc.
If you're new to ruby, I would highly recommend you use a ruby version manager, i.e. RVM or perhaps RBENV, although I tend to find RVM a bit simpler and less problematic.
My other personal favorite ruby code hacking/inspecting tool is PRY
I have an air gapped network that I use for development. Is there any way that I can easily download a snapshot of rubygems.org to import to the gem server running on said network?
I saw the help article on the rubygems site about how to get specific gems with no network:
$ gem install rails -i repo --no-rdoc --no-ri
I want to try to get everything at once. Any idea how big this would be even without the rdoc and ri?
I have not ever used it, but googling, this tool claims to be able to do that:
https://github.com/rubygems/rubygems-mirror
you can build a gem server at your server.
I think this article can help you.
http://guides.rubygems.org/run-your-own-gem-server/
I have installed Ruby on my system, and now I want to install Compass. But when I execute the gem install compass command, it shows an error like this:
could not find valid gem 'compass' <>=0> in any repositary
And also:
SocketError: getadressinfo: no such host is known.<http://rubygems.org/latest_specs.4.8.gz>
I don't know what the problem is. If I run ruby -v, it shows the Ruby version. So what's the problem with installing Compass?
Can anyone explain this to me properly? I've searched Google, but all I could find was some proxy problem - and I couldn't understand how to set the proxy at all.
I'm using Windows and a company internet connection, so I don't know the username and password of my proxy.
I was behind a proxy and HumberFrench's solution above helped:
Go to Ruby bin folder:
cd c:/Ruby193/bin
And then install compass gem:
gem install compass --http-proxy http://<proxy_adreess>:<port_of_proxy>
Another tip: am on Aptana Studio, so this could be run from within Aptana's terminal.
Cant up-vote so adding this here.
I had the same problem, finally solved it manually.
Goto the rubygems compass page, and download the gem by clicking the Download link. Scroll down and you will see three Runtime Dependencies. Goto each of them and download those gems also. Put all of them in a directory, and try
gem install downloaded_compass_filename
This should solve your problem.
If it gives an repository not found error message, you can force gem to try local files through the gem --local install option
if you use a proxy, and get error, do it
gem install compass --http-proxy http://<proxy_adreess>:<port_of_proxy>
gem install -h gives you a lor of options
The proxy is the most likely cause. You will have to get permission from the network admin, or manually download compass. For more info, See this SA post.
If you decide to go the manual route here is a link to the RubyGems compass page. This not ideal, but also better than having to write css without compass magic ^^
Good luck!
On windows i had a few instalations of ruby:
C:\ruby187
and
C:\Ruby200-x64
install compass in both places, using:
gem install compass
Try running the install command in the bin folder.
$ cd C:\Your_Ruby_Folder\bin
$ gem install compass
I have same problem and i resolve it with.
Uninstall ruby end deleted folder ruby
Download ruby version 1.9.x
After thet install sass
last stem: install compass
Currently Rubygems.org is down - the website reports an error, and a few gem install tasks are returning 500 errors.
Is there a mirror / backup source of gem files, or is rubygems.org essentially a single point of failure within the ruby gem installation process ?
As per several folks on Twitter, add this to your Gemfile:
source 'https://production.cf.rubygems.org'
Also, if you're not using Bundler you can just run:
$ gem source -a 'https://production.cf.rubygems.org'
For the record, the folks on Twitter include:
laizer, iltempo, and jimneath. Major thanks to them for saving my morning :)
same issue affecting all git push to Heroku
solved the same was by changing the source on GemFile to the http://production.cf.rubygems.org
Mirror for Asia/Pacific Region: https://ruby.taobao.org/ (recommended, high availability, syncing every 15 min)
Other mirrors:
https://gems.cloudafrica.net/
https://tokyo-m.rubygems.org/
Having experienced my share of flaky network connections I find I've most often got the .gem files I need on my system, it's just a matter of finding them and installing them locally.
Use the find command to find local .gem files and install them directly with gem install [file].
find ~/.rbenv/versions -type f -name 'minitest*.gem'
That works for individual gems but if you need to install dependencies, etc. it can be a pain.
If you've got the gem on some other computer, or on other rubies on the same
computer, use
gem server
to create your own gem server.
Otherwise, download the source code for the gem in question from github, and do
the rake task to build the gem.