Pushing Gem to Hosted Credentialed Feed Is Failing - ruby

I'm trying to push a gem to hosted Artifactory and am encountering problems every step of the way.
My environment is:
Operating System: Windows 7 x64 Professional
Ruby: ruby 1.9.3p545
I had to do a trick with cacert.pem to add the artifactory url to my list of sources, but that part is working now. The next step in Artifactory documentation is to get an api key and pipe it to ~/.gem/credentials.
When I do that the api key downloads successfully, but gem completely breaks.
gem
C:/ruby193/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>): control characters are not allowed at line 1 column 1 (Psych::SyntaxError)
from C:/ruby193/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
from C:/ruby193/lib/ruby/1.9.1/psych.rb:151:in `parse'
from C:/ruby193/lib/ruby/1.9.1/psych.rb:127:in `load'
from C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:253:in `load_file'
from C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:223:in `load_api_keys'
from C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:208:in `initialize'
from C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:78:in `new'
from C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:78:in `do_configuration'
from C:/ruby193/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:51:in `run'
I can't even use gem as long as the credentials file is there, so I have to remove it.
If I try to push without the credentials file and using the --host option, gem seems to ignore the --host options.
gem push .\my_gem-0.0.1.0.beta.gem --host $artifactory.source
Enter your RubyGems.org credentials.
Don't have an account yet? Create one at http://rubygems.org/sign_up
Email:
Password:
Pushing gem to https://rubygems.org...
HTTP Basic: Access denied.
This is a proprietary gem, so publishing to rubygems.org is NOT an option. There definitely seems to be a problem with my environment, but I've been unable to figure out what it is--and none of the other documentation of SO questions seem to be on point.
I know that I'm going to need to get gem to read the credentials file to push successfully, but it seems like a more basic issue that gem is ignoring the --host parameter.

It took a lot of effort, but I think I've resolved my issues. It was a problem in 2 parts.
Solution Part 1
With respect to the issue of gem ignoring the --host option, this is resolved by updating gem.
Apparently the version of gem that ships with ruby 1.9.3v545 on Windows is broken. After updating gem it acted like it was trying to upload to the correct url.
Solution Part 2
The second issue involves a corrupted credentials file. What's happening here is that when piping the output from the curl command into the credentials file, the credentials file is being encoded with Unicode. To resolve this I used a slightly different curl command (in powershell)
curl $url | Out-File ~/.gem/credentials -Encoding "ASCII"
Now I'm able to upload the gem successfully.

If the SSL_CERT_FILE environment variable trick doesn't work, you can also try editing your .gemrc file as follows:
:ssl_ca_cert: C:\\path\\to\\cacert.pem

Related

Connection Refused RubyGems

I'm currently attempting to install a gem gem install micromidi. Whenever I run it from terminal I receive this error:
ERROR: Could not find a valid gem 'micromidi' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - Errno::ECONNREFUSED: Connection refused - connect(2) for "rubygems.global.ssl.fastly.net" port 443 (https://api.rubygems.org/latest_specs.4.8.gz)
I'm not behind a proxy and I have an internet connection. I've installed gems before and have never had a problem. What's wrong and how do I fix this?
There's been a few recent merges of commits regarding ssl and mentioning "fastly", like this search of the repo: https://github.com/rubygems/rubygems/search?o=desc&q=fastly&s=created&type=Issues
Also, 2.6.3 / 2016-04-05 […] New fastly cert. Pull request #1548 by David Radcliffe see: https://github.com/rubygems/rubygems/blob/ccb9c3300c063f5b5656669972d24a10ef8afbf5/History.txt#L63
ANSWER
I recommend manually updating to RubyGems v2.6.6 - June 22, 2016 via https://rubygems.org/pages/download:
If you don't have any RubyGems installed, there is still the pre-gem
approach to getting software, doing it manually:
Download from above
Unpack into a directory and cd there
Install with: ruby setup.rb (you may need admin/root privilege)
RESOURCES
If the above doesn't resolve the issue, here are some additional resources:
[Comcast ISP] issue: https://github.com/rubygems/rubygems/issues/1001
[OS X] Helpful Stack Overflow question: "gem install rails" fails with DNS error
[Windows] Workaround RubyGems' SSL errors on Ruby for Windows (RubyInstaller), via https://gist.github.com/luislavena/f064211759ee0f806c88#manual-solution-to-ssl-issue:
Step 1: Obtain the new trust certificate
[…]
We need to download AddTrustExternalCARoot-2048.pem[ https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem ]
Use the above link and place/save this file somewhere you can later
find easily (eg. your Desktop).
IMPORTANT: File must have .pem as extension. Browsers like Chrome will
try to save it as plain text file. Ensure you change the filename to
have .pem in it after you have downloaded it.
Step 2: Locate RubyGems certificate directory in your installation
In order for us copy this file, we need to know where to put it.
Depending on where you installed Ruby, the directory will be
different.
Take for example the default installation of Ruby 2.1.5, placed in
C:\Ruby21
Open a Command Prompt and type in:
C:\>gem which ruby gems
C:/Ruby21/lib/ruby/2.1.0/rubygems.rb
Now, let's locate that directory. From within the same window,
enter the path part up to the file extension, but using
backslashes instead:
C:\>start C:\Ruby21\lib\ruby\2.1.0\rubygems
This will open a Explorer
window inside the directory we indicated.
Step 3: Copy new trust certificate
Now, locate ssl_certs directory and copy the .pem file we obtained
from previous step inside.
It will be listed with other files like GeoTrustGlobalCA.pem.

Getting SSL error in ruby on Windows

I get the following error:
C:\Users\user\Desktop\folder>ruby exchange_rate.rb
C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect
returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify fai
led (OpenSSL::SSL::SSLError)
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:933:in `connect'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
from C:/Ruby23-x64/lib/ruby/2.3.0/net/http.rb:852:in `start'
from exchange_rate.rb:55:in `<main>'
According to
https://gist.github.com/luislavena/f064211759ee0f806c88
and other places with the exact same info this affects only rubygems versions up to 2.2.x
However my installation is:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x64-mingw32] with rubygems 2.5.1
and I still get it
I tried the manual solution there, after looking for the .pem file somewhere else https://github.com/rubygems/rubygems/blob/master/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem
since the link doesn't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x
IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN
AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH
YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5
6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC
Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX
c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a
mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
-----END CERTIFICATE-----
which is exactly the same thing I have
I upgraded rubygems to 2.6.4 still getting the same problem
Can anyone can help me get this working?
What worked for me is downloading a certificate file and pointing the SSL_CERT_FILE environment variable to it. My source is this gist by fnichol. (I was following the "The Manual Way (Boring)" instructions.)
Download http://curl.haxx.se/ca/cacert.pem to some permanent location.
Set environment variable SSL_CERT_FILE to the path of the downloaded file.
Now suddenly HTTPS requests (not related to gem installation) would work for me on Windows 10 using Ruby 2.2.x (x64).
Solved my problem by installing this gem
net_http_ssl_fix
Documentation here:
http://blog.liveeditorcms.com/net-http-ssl-fix-gem/
I don't know why it fixes, why the need of another gem on top of the regular one, but, what the hell, it works!
Any one that has installed 2.3.1 this link solved my SSL problems with installing gems in windows.
https://superdevresources.com/ssl-error-ruby-gems-windows/
Summary:
Download .pem file from here http://curl.haxx.se/ca/cacert.pem and save to C:\Rails\Installer\cacert.pem.
Right click computer and select properties.
Then click Advanced system settings and then Environment Variables.
Create a new system variable with SSL_CERT_FILE as name and C:\Rails\Installer\cacert.pem as path.
Open a command prompt and verify that you can install a gem.
I.E - gem install watir
For me, upgrading to ruby v2.4.3 via the RubyInstaller-2.4.3-1 (for windows) helped. The installer can be downloaded from https://rubyinstaller.org.

Gitorious: git-poller won't start

I just installed a fresh gitorious on my server and wanted to test it when I found out that the git-poller didn't run. And it also didn't want to start.
I followed this guide: http://gitorious.org/gitorious/pages/DebianSqueezeInstallation, my system is Debian Squeeze and Ruby -v says ruby 1.8.7
Everything from that guide works so far. The system is up and running but I can't start the poller. All the poller writes into the logs is the following:
tmp/pids/poller.log
*** below you find the most recent exception thrown, this will be likely (but not certainly) the exception that made the application exit abnormally ***
#<MissingSourceFile: no such file to load -- user_auto_completions_helper>
*** below you find all exception objects found in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***
#<NoMemoryError: failed to allocate memory>
#<SystemStackError: stack level too deep>
#<fatal: exception reentered>
#<LoadError: no such file to load -- daemons>
#<TypeError: Expected a filter, an endpoint, a callable or a list of any of these.>
#<NameError: uninitialized constant ActiveMessaging>
#<MissingSourceFile: no such file to load -- user_auto_completions_helper>
tmp/pids/poller.output
/home/clients/client1/web85/web/vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant ActiveMessaging (NameError)
from /home/clients/client1/web85/web/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
from /home/clients/client1/web85/web/vendor/rails/activesupport/lib/active_support/dependencies.rb:92:in `const_missing'
from /home/clients/client1/web85/web/lib/gitorious/messaging/stomp_poller.rb:13
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:203:in `load'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:203:in `start_load'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:292:in `start'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/controller.rb:70:in `run'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons.rb:143:in `run'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `call'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `catch_exceptions'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons.rb:142:in `run'
from script/poller:30
I'm using ispconfig as a webserver management tool, that's where the weird paths are from. I changed all paths from the howto to fit, tho.
Anybody got an idea? I can provide more material if needed, but I just don't know what could be usefull. This is my first question on stackoverflow so please don't shoot me if I didn't do everything right :)
After a lot of reading and trial and error (I started about 3 times from scratch, trying Ruby 1.9.2 and REE both from source and with RVM) I tried another howto[1] which had one big difference to the first one: It suggested downloading and installing Rubygems 1.4.2 instead of the apt-version of Rubygems.
At first I didn't want to do that because I was afraid that it would break my system (there are a lot of other things running on that server, including Redmine) which it did, but after I re-installed all missing gems everything worked again.
Now everything (Gitorious and Redmine) is working with apt-version of Ruby 1.8.7 and the non-apt-version of Rubygems 1.4.2.
[1] http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server/
Since I stumbled upon another, hopefully last problem:
I installed gitorious for my standard web user (in order to respect ISPConfig's policy) and made a new git-user for the repositories. To be able to exchange data I added both to the same usergroup and fixed the permissions.
The problem I ran into was that the git poller added new repositories for his own, that means "git:git" instead of "git:sharedgroup". To fix this you just have to set the default group id for the git-folder (/var/git in my case):
chgrp -R <group_name> /var/git
chmod -R g+s /var/git
It appears that the two commands above did work but adding a new project broke everything again because the git-poller added a folder for the project and the repository which resulted in the repository-folder having the wrong owner again.
I (hopefully) fixed that with changing my /etc/init.d/git-poller script from
/bin/su - git -c "cd /var/www/git.mydomain.com/web;RAILS_ENV=production script/poller $#"
to
/bin/su - git -c "newgrp <group_name> && cd /var/www/git.mydomain.com/web;RAILS_ENV=production script/poller $#"

Issue in uploading gem to Geminabox

I stood up a Rack server with Geminabox, running on my machine at http://localhost:9292. Now I was trying to upload the gem to the server (from a different tab on the terminal acting like a client), but when I type:
gem sources -a http://localhost:9292
I get the following error:
Error fetching http://localhost:9292:
bad response Not Found 404 (http://localhost:9292/specs.4.8.gz)
There is a trailing colon and I'm a bit lost, any help on that?
Thanks!
You need to upload at least one gem before Geminabox starts to serve the necessary files.
(I know this is an old question but I came here from google so others might as well)

How can I get past "http://gems.rubyforge.org/ does not appear to be a repository" error message

Question 828421 asked similar question, but received only one real answer (update rubygems) and that attempt results in the same error.
Ruby version 1.9.1.p243 on Windows. Included Gem, version 1.3.5.
Never installed any gems before; never did any special config for this Ruby.
Ruby itself works, as does irb, and "gem" operates but can't do install (and maybe other ops).
Tried this (from a book):
gem install rspec
Got this:
ERROR: http://gems.rubyforge.org/ does
not appear to be a repository
ERROR: While executing gem ...
(Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: The storage control blocks were destroyed.
(http://gems.rubyforge.org/yaml)
When I go to that URL (without "yaml") using MSIE7, I get a page titled "Gemcutter | awesome gem hosting" and have no problem wandering around that site. So I don't -think- it's a proxy problem (though this is all from inside corporate firewall/proxies/etc).
When I go to that URL -with- "yaml", it goes to "http://production.s3.rubygems.org/yaml" and shows what I assume is an update specification page, starting with this:
--- !ruby/object:Gem::SourceIndex
I didn't destroy any "storage control blocks". So what is preventing gem from installing a gem?
Web search shows MANY people having this same problem over a long span of time, but I have yet to see anyone say "It's because of THIS, so do THIS to fix it." Well, someone suggested updating "gem", but trying that gets same error.
Help please?
Your browser might be using system-wide proxy settings or some sort of automatic configuration. The gem command probably doesn't. I'm behind an university proxy and I can't install/update any gems normally, but can access everything with my browser. To install gems, I normally create a tunnel to my server so I can bypass the proxy server.
This might help you to configure the proxy settings for the gem command: How do I update Ruby Gems from behind a Proxy (ISA-NTLM)
Sample:
sudo gem install nifty-generators -p http://proxy:port
It works well.
If your proxy requires authentication, then use:
gem install --http-proxy http://USERNAME:PASS#HOST:PORT gem_name
This can "at times" mean that for some reason rubygems.org is down currently, and so your local "invisible proxy" is returning you a 404 or what not.
#Tomas Markauskas didn't work for me because i'm not behind a proxy. And I didn't find a solution anywhere, I tried disable my AV and firewall, didn't
This was the solution for me:
gem install rails -r -w -p
Hope this will help people with the same problem.
EDIT: I have Windows 7 64bit.

Resources