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.
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'm developing a couple of private gems and I think I don't understand correctly the PATH/GEM_PATH and/or Bundler/RVM installation flow, would love if someone could chip in.
I have a repository with two gems (A & B for simplicity sake). I've developed the gems using the scaffolding + following the guidelines provided by this bundler tutorial.
Thanks to the Bundler project I have a few Rakefile tasks like rake build, rake install, rake install:local and rake release. Because of the private nature of these gems I can't release them to RubyGems (and we haven't looked into hosting our rubygems).
My machines are using RVM to manage ruby versions and Bundler version 1.15.1
What I want to do: Assuming a new machine/developer trying out the project, ideally we would cd into each of the subfolders (currently 2, gem A and gem B), run rake install and after that we should have the gems available system wide for the current user.
What is happening: The gems are built and work properly, but they are only available inside the subfolder of each gem i.e. gem A is only available inside the subfolder A and gem B is only available inside subfolder B.
What I've tried: So, after rake build/install/install:local a new .gem file is generated under pkg. I've tried to manually install the "compiled" file using gem install pkg/A.gem, gem install --local pkg/A.gem and gem install --local --user-install pkg/A.gem without success. (there are plenty of SO questions/answers about this)
I believe this has something to do with the PATH variables, but like I said before I don't fully understand the way they are managed. I get the following results from these commands:
# Our gem
> gem which A
/home/ubuntu/.rvm/gems/ruby-2.4.0/gems/A-0.1.8/lib/A.rb
# Pry, available globally
> gem which pry
/home/ubuntu/.rvm/gems/ruby-2.4.0/gems/pry-0.11.1/lib/pry.rb
I've been lost and frustrated for far too long now, any help is appreciated. Also open to hear suggestions of better private gem installation flows :)
Yes, it has something to do with your PATH variables. Your installation seems to be good.
I advise you to first affirm your gems installation path with:
echo $GEM_HOME
The double check your PATH to ensure its present and also confirm that the GEM home is also where the gem got installed into from the rake install
echo $PATH
If not, put it in your path and you should be fine with something like this:
echo PATH=$PATH:$GEM_HOME >> ~/.bashrc
source ~/.bashrc
Build your gem as per that guide you linked. You should end up with a gem file. Distribute this as you see fit (I use rsync/crontab to download newer gem versions but anything goes). User can install the gem as follows:
gem install --user-install /path/to/your/file.gem
This will install the gem in the user's ~/.gem/ruby/<version>/gems/<your-gem-name> directory.
Tried it with an empty gem (foodie, as in that example guide) and it works fine. But if you don't specify the --user-install parameter it will try to install in the system ruby dir (/usr/lib/ruby/gems...)
I want to put a debugger in a file for testing, but can't find where Bundler installs gems pulled from Github on my local machine.
I've looked at this thread http://bundler.io/v1.5/git.html which shows how to setup a local file repo to pull from, but I would rather avoid this as my situation is a one off debugging scenario.
I use rbenv for my ruby and gem management. When I pull in a gem from a git repo, it places the files for the gem here:
/usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/gem-name-SHA/
On my machine bundler installed the gem in:
~/.rvm/gems/ruby-2.3.3/bundler/gems/gem-from-github
gem which [GEM] doesn't work on its own, but bundle exec gem which [GEM] does.
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/
My connection to default gem source server http://rubygems.org/ is slow. So I am looking for a method to build a private gem server on a machine which I have fast connection to. I have some questions after reading gems doc:
If I have multiple gem sources , what is the order which source is used when running gem install xxx?
Will any method documented in http://docs.rubygems.org/read/chapter/18 help build a transparent gem server? "Transparent" means I need this only one gem server in my gem sources, and when I request a gem from this server, it will first serve the gem from cache. If the gem is not in cache yet, the server will try to download it from http://rubygems.org/, serve and cache it.
If the answer for question 2 is "No", how can I build a transparent gem source server?
I'd suggest just installing the pre-release bundler, which is several orders of magnitude faster due to major architectural changes. It's not just your connection to rubygems that is slow; it's that painful for all of us ;) gem install bundler --pre will give you a much faster bundler.
That said, if you really want a loca gem server, try Gem in a box:
https://github.com/cwninja/geminabox
Here are a few projects that are specifically made to run a RubyGems.org mirror:
https://github.com/YorickPeterse/gem-mirror
https://github.com/rubygems/rubygems-mirror