Ruby gem cucumber SSL error and Gem sources - ruby-on-rails

I was trying to install cucumber gem for Ruby.
Although there were few topics somewhat related to this, I can't find exact question with exact answer. When on Windows I try to run the command gem install cucumber and the console returned:
ERROR: Unable to download data from https://rubygems.org/ -
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B:
certificate verify failed
(https://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz)
Then, I googled for a solution and found some suggestions to remove source in here. I ran gem sources -r and it has been removed.
But did that not only in cucumber. Now I'm even unable to add source.

I had the same issue a while back after moving to ruby 2.0.0
Follow the following steps to solve it
1)Visit the url http://curl.haxx.se/ca/cacert.pem save the contents as a .pem file(Do not save it as a text file.Make sure the extension is .pem)
2)Copy the file to any path in your local eg: C:\ruby200\ca_cert.pem (in my case)
3)Now add an Environment variable with Variable SSL_CERT_FILE and value "C:\ruby200\ca_cert.pem"(without quotes)(path is in my case.Replace with appropriate path) (Environment variables can be added by navigating to Computer -> Advanced Settings -> Environment Variables)
4)Close all your command prompts and restart them.Things should work fine now

This issue occurs due to changes in rubygems.org infrastructure.
Please follow the link below:
https://gist.github.com/luislavena/f064211759ee0f806c88
Hope it will help you.

Related

How to install mupdf on heroku?

I've upgraded to rails 5.2 and am implementing ActiveStorage. ActiveStorage uses mutool for PDF processing. I have successfully installed mutool locally using homebrew.
mutool is a bit confusing.
rails docs claim to require "mutool",
homebrew installs "mupdf-tools",
and heroku wants "mupdf".
I have successfully installed apt and mupdf on heroku following these steps:
- add a new Aptfile to the root of my application with only "mupdf" listed
- commit and push the Aptfile
- THEN run heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
- push again so heroku will finish installing apt and mupdf
mupdf builds successful during the push
heroku buildpacks now returns
1. https://github.com/heroku/heroku-buildpack-apt
2. heroku/ruby
If I refresh a page calling for a variant on a PDF, the image fails to process and the job kicks back the following error:
Errno::ENOENT: No such file or directory - mutool
It seems mutool and mupdf are synonomous...so, I tried swapping out mutool for mupdf in my Aptfile...that failed to build from "...not found'.
Anyone know what action I need to take?
PS: This is part of implementing rails 5.2 using ActiveStorage.
UPDATE
I added mupdf-tools to Aptfile and that seems to fix the "no such file or directory" error. I don't know for sure because a new errors surfaces
MiniMagick::Invalid: `identify /tmp/mini_magick20180105-4-pvub9r` failed with error: identify.im6: no decode delegate for this image format `/tmp/mini_magick20180105-4-pvub9r' # error/constitute.c/ReadImage/544.
MiniMagick::Error: `identify -format %m %w %h %b /tmp/ActiveStorage20180105-4-1f46tem[0]` failed with error: identify.im6: no decode delegate for this image format `/tmp/ActiveStorage20180105-4-1f46tem' # error/constitute.c/ReadImage/544.
Heroku recommends Poppler as an alternative to MuPDF for licensing reasons (MuPDF has a commercial license).
They created a buildpack for Active Storage Previews that covers PDFs as well as Video files.
I know this is a bit old, but if you're still having this issue I was able to resolve this by updating the version of mupdf-tools to at least 1.8.
To do this with Heroku, you'll want to link directly to the latest release.
Add heroku-buildpack-apt, and then add a custom Aptfile. Note that you'll need to add the Aptfile first in order for the buildpack to work.
Here is what my Aptfile looks like:
:repo:deb http://archive.ubuntu.com/ubuntu artful main universe
imagemagick
ffmpeg
mupdf-tools
To test that you have the right version, you can use heroku ps:exec to test. Run mutool -v and you should be on version 1.11.

OpenSSL::SSL::SSLError Handshake Failure with Homebrew OpenSSL

I'm trying to make an API request in a Ruby app, on MacOSX.
When I try something like this:
RestClient.get("https://api.foursquare.com/v2/venues/explore?near=NYC&query=McDonalds")
I get this (same when it's http):
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server hello A: sslv3 alert handshake failure
from /Users/sasha/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:920:in `connect'
(If I try (open("https://...")), I get this:
OpenURI::HTTPError: 400 Bad Request
from /Users/sasha/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/open-uri.rb:353:in `open_http'
I took a look at some SO discussions about this, and in particular this one led me to believe it was an issue with my OpenSSL not finding the right cert.pem file. I'm using Homebrew, and my Homebrew OpenSSL is installed in /usr/local/bin. The original Mac version of OpenSSL is at /usr/bin, I think.
I followed the suggestions to set a global ENV variable SSL_CERT_FILE to the path to my cert.pem file as installed by Homebrew - /usr/local/etc/openssl/cert.pem, - and when I echo that variable, it is set correctly, but when I re-open a Ruby console and try again, I get the same error. Thoughts on what I'm doing wrong? I don't know much about OpenSSL, and I'm totally flummoxed by this one, given that it seems to be finding my certificate correctly.
EDIT
When I run which openssl, it shows the Mac version -- /usr/bin/openssl. This makes sense, given Homebrew's install notes:
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
The OpenSSL provided by OS X is too old for some software.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
Is that the problem? I'm including the wrong cert.pem file given my version of OpenSSL?
state=SSLv3 read server hello A: sslv3 alert handshake failure
That is usually not a problem of a bad or missing certificate, but that the server does not like what the client sends, like unsupported SSL version or no appropriate ciphers offered by the client.
I get this error with this host if I try to connect with SSL3.0 instead of TLS1.0 or higher, so please make sure that you don't use SSL3.0 anymore.
If this does not help make a packet capture of the traffic and post it to cloudshark.org so that one can have a look about the traffic details.

How can I see the source code of a gem installed on my machine?

I installed Devise in my Rails app and I want to read through the source code and learn how it works. I looked through the entire folder structure of my Rails app, but couldn't find any code (except for the method calls).
I know I can see the source from the Github repository but I would like to see it in my editor and on my local machine.
I'm guessing this code must be in some main Ruby directory, but I'm having trouble locating it. Any help is appreciated. Thanks.
Besides Sergio's suggestion, there is another option.
Within your Rails path
$ bundle open devise
This will open the installed gem in editor with the version specified in Gemfile, very handy.
Try gem unpack, it will copy source of a gem to current directory. For example,
gem unpack rails
Documentation: gem unpack.
Simply run bundle show <gem-name>,
it will list the absolute path of gem source code and in next step simply open source code using text editor like this
subl <gem-code-absolute-path>
For Example
Let's assume you want to read kaminari gem code
bundle show kaminari
/home/abdullah/.rvm/gems/ruby-2.3.0#your_gem_name/gems/kaminari-0.16.3
next step (subl is command to open with Sublime Text Editor)
subl /home/abdullah/.rvm/gems/ruby-2.3.0#your_gem_name/gems/kaminari-0.16.3
Run gem environment - this will display you all the information about your gems, including their location.
Additionally I would advise you to install some IDE with go to source feature - RubyMine is just brilliant (and has 30-day-long free trial), if you want to go for absolutely free go with NetBeans together with Ruby plugin. This feature allows you to navigate quickly to source of clicked method, regardless whether it is defined inside your code or inside the gem.
Clone the github repo in your local machine and explore it using your prefered editor:
git clone https://github.com/plataformatec/devise.git

Ruby on Rails - Windows 7 installation, non-english characters in user name

I'm trying to install Ruby on Rails on Windows 7 but I have a problem immediately at the beginning of the configuration. This is the first time I'm trying RoR.
I downloaded RailsInsaller from http://railsinstaller.org/ and installed it successfully. Immediately after the installation when I need to configure environment, I receive an error in cmd:
# Rails Environment Configuration.
open C:\\Users\\\246ero/.ssh/id_rsa failed: No such file or directory.
The system cannot find the path specified.
D:/ROR/RailsInstaller/scripts/config_check.rb:87:in `initialize': No such file o
r directory - C:\Users\|ero/.ssh/id_rsa.pub (Errno::ENOENT)
from D:/ROR/RailsInstaller/scripts/config_check.rb:87:in `open'
from D:/ROR/RailsInstaller/scripts/config_check.rb:87:in `<main>'
What is the solution to this problem? Or is there any other way to install RoR on Windows 7? Thank you for your help.
I know it's an old post, but I had the same issue, and I think I've found the solution.
The path that ssh is trying to access contains that character "|" that Ruby doesn't like, that's because your username is "|ero".
To resolve this issue, you should either change your windows username (this should prevent you from a lot of troubles in your future setup), or change your HOME environment variable so that it points to a folder that doesn't contain any accent, space or strange character in its path ! And then re-install Ruby :)
Hope it helps!
I have installed Ruby on Rails in Windows 7. To install ruby on rails on Windows7 follow the steps:
1) install ruby on windows 7. Download from: http://rubyinstaller.org/
2) check ruby is installed correctly by this command ruby -v if this gives command not found error, then set RUBY_HOME="path/to/ruby/bin" in environment variables.
3) install rails by command gem install rails.
and you are done. Enjoy Ruby On Rails on Windows7.
I faced exactly the same problem and found its solution - under Windows XP Pro SP3. You should manually generate the ssh keys pair. Run ssh-keygen from a bash
shell so it generated both id_rsa and id_rsa.pub.
That's easy as 3 mouseclicks:
Start - Programs - Rails Installer - Git Bash
type there "ssh-keygen". Press Enter 2 or 3 times. You're done! The problem is gone now.

The system cannot find the path specified when starting Ruby and Rails command prompt

I just started learning rails a week ago and everything worked until today. Now when I start the Ruby command prompt, it says:
The system cannot find the path specified.
# Under Rails Environment Configuration.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
---
The paths for ruby and rails show up correctly.
I'm using Windows Vista 32-bit. Any help would be greatly appreciated, thanks!
You've probably used "Ansicon" - a program to get the colors in windows prompt right. If you installed it permanently with -i parameter and consequently moved/deleted its directory, it would lead to this error. (I've just experienced it)
The solution is to renew the location of the ansicon data files or to remove the following registry entry:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
You can find more on this issue at http://carol-nichols.com/2011/03/17/the-system-cannot-find-the-path-specified/
Good luck!
I had the same problem in Windows 7 and solved it by adding Git/bin directory to the system path variable (found the answer here). Hope this helps someone!
None of the answers above helped me. My issue was whenever i typed rail -v it gave me the same error. I had to install rails, i used the following command:
gem install rails --no-document
you can check out the following installation steps to get around the error:
http://docs.railsbridge.org/installfest/windows

Resources