ruby script/plugin discover RuntimeError [duplicate] - ruby-on-rails

The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method?
... or am I just being lazy?
Note: rubysspi-1.2.4 does not work.
This also works for "igem", part of the IronRuby project

For the Windows OS, I used Fiddler to work around the issue.
Install/Run Fiddler from www.fiddler2.com
Run gem:
$ gem install --http-proxy http://localhost:8888 $gem_name

I wasn't able to get mine working from the command-line switch but I have been able to do it just by setting my HTTP_PROXY environment variable. (Note that case seems to be important). I have a batch file that has a line like this in it:
SET HTTP_PROXY=http://%USER%:%PASSWORD%#%SERVER%:%PORT%
I set the four referenced variables before I get to this line obviously. As an example if my username is "wolfbyte", my password is "secret" and my proxy is called "pigsy" and operates on port 8080:
SET HTTP_PROXY=http://wolfbyte:secret#pigsy:8080
You might want to be careful how you manage that because it stores your password in plain text in the machine's session but I don't think it should be too much of an issue.

This totally worked:
gem install --http-proxy http://COMPANY.PROXY.ADDRESS $gem_name

I've been using cntlm (http://cntlm.sourceforge.net/) at work. Configuration is very similar to ntlmaps.
gem install --http-proxy http://localhost:3128 _name_of_gem_
Works great, and also allows me to connect my Ubuntu box to the ISA proxy.
Check out http://cntlm.wiki.sourceforge.net/ for more information

I tried some of these solutions, and none of them worked. I finally found a solution that works for me:
gem install -p http://proxy_ip:proxy_port rails
using the -p parameter to pass the proxy. I'm using Gem version 1.9.1.

Create a .gemrc file (either in /etc/gemrc or ~/.gemrc or for example with chef gem in /opt/chef/embedded/etc/gemrc) containing:
http_proxy: http://proxy:3128
Then you can gem install as usual.

This solved my problem perfectly:
gem install -p http://proxy_ip:proxy_port compass
You might need to add your user name and password to it:
gem install -p http://[username]:[password]#proxy_ip:proxy_port compass

If you are having problems getting authenticated through your proxy, be sure to set the environment variables in exactly the format below:
set HTTP_PROXY=some.proxy.com
set HTTP_PROXY_USER=user
set HTTP_PROXY_PASS=password
The user:password# syntax doesn't seem to work and there are also some badly named environment variables floating around on Stack Overflow and various forum posts.
Also be aware that it can take a while for your gems to start downloading. At first I thought it wasn't working but with a bit of patience they started downloading as expected.

Quick answer : Add proxy configuration with parameter for both install/update
gem install --http-proxy http://host:port/ package_name
gem update --http-proxy http://host:port/ package_name

I tried all the above solutions, however none of them worked. If you're on linux/macOS i highly suggest using tsocks over an ssh tunnel. What you need in order to get this setup working is a machine where you can log in via ssh, and in addition to that a programm called tsocks installed.
The idea here is to create a dynamic tunnel via SSH (a socks5 proxy). We then configure tsocks to use this tunnel and to start our applications, in this case:
tsocks gem install ...
or to account for rails 3.0:
tsocks bundle install
A more detailed guide can be found under:
http://blog.byscripts.info/2011/04/bypass-a-proxy-with-ssh-tunnel-and-tsocks-under-ubuntu/
Despite being written for Ubuntu the procedure should be applicable for all Unix based machines. An alternative to tsocks for Windows is FreeCap (http://www.freecap.ru/eng/). A viable SSH client on windows is called putty.

Posts abound regarding this topic, and to help others save hours of trying different solutions, here is the final result of my hours of tinkering.
The three solutions around the internet at the moment are:
rubysspi
apserver
cntlm
rubysspi only works from a Windows machine, AFAIK, as it relies on the Win32Api library. So if you are on a Windows box trying to run through a proxy, this is the solution for you. If you are on a Linux distro, you're out of luck.
apserver seems to be a dead project. The link listed in the posts I've seen lead to 404 page on sourceforge. I search for "apserver" on sourceforge returns nothing.
The sourceforge link for cntlm that I've seen redirects to http://cntlm.awk.cz/, but that times out. A search on sourceforge turns up this link, which does work: http://sourceforge.net/projects/cntlm/
After downloading and configuring cntlm I have managed to install a gem through the proxy, so this seems to be the best solution for Linux distros.

A workaround is to install http://web.archive.org/web/20060913093359/http://apserver.sourceforge.net:80/ on your local machine, configure it and run gems through this proxy.
Install: Just download apserver 097 (and not the experimental 098!) and unpack.
Configure: Edit the server.cfg file and put the values for your MS proxy in PARENT_PROXY and PARENT_PROXY_PORT. Enter the values for DOMAIN and USER. Leave PASSWORD blank (nothing after the colon) – you will be prompted when launching it.
Run apserver: cd aps097; python main.py
Run Gems: gem install—http-proxy http://localhost:5865/ library

I am working behind a proxy and just installed SASS by downloading directly from http://rubygems.org.
I then ran sudo gem install [path/to/downloaded/gem/file]. I cannot say this will work for all gems, but it may help some people.

This worked for me in a Windows box:
set HTTP_PROXY=http://server:port
set HTTP_PROXY_USER=username
set HTTP_PROXY_PASS=userparssword
set HTTPS_PROXY=http://server:port
set HTTPS_PROXY_USER=username
set HTTPS_PROXY_PASS=userpassword
I have a batch file with these lines that I use to set environment values when I need it.
The trick, in my case, was HTTPS_PROXY sets. Without them, I always got a 407 proxy authentication error.

If you are on a *nix system, use this:
export http_proxy=http://${proxy.host}:${port}
export https_proxy=http://${proxy.host}:${port}
and then try:
gem install ${gem_name}

rubysspi-1.3.1 worked for me on Windows 7, using the instructions from this page:
http://www.stuartellis.eu/articles/installing-ruby/

If you want to use SOCKS5 proxy, you may try rubygems-socksproxy https://github.com/gussan/rubygems-socksproxy.
It works for me on OSX 10.9.3.

If behind a proxy, you can navigate to Ruby downloads, click on Download, which will download the specified update ( or Gem ) to a desired location.
Next, via Ruby command line, navigate to the downloaded location by using : pushd [directory]
eg : pushd D:\Setups
then run the following command: gem install [update name] --local
eg: gem install rubygems-update --local.
Tested on Windows 7 with Ruby update version 2.4.1.
To check use following command : ruby -v

Rather than editing batch files (which you may have to do for other Ruby gems, e.g. Bundler), it's probably better to do this once, and do it properly.
On Windows, behind my corporate proxy, all I had to do was add the HTTP_PROXY environment variable to my system.
Start -> right click Computer -> Properties
Choose "Advanced System Settings"
Click Advanced -> Environment Variables
Create a new System variable named "HTTP_PROXY", and set the Value to your proxy server
Reboot or log out and back in again
Depending on your authentication requirements, the HTTP_PROXY value can be as simple as:
http://proxy-server-name
Or more complex as others have pointed out
http://username:password#proxy-server-name:port-number

for anyone tunnelling with SSH; you can create a version of the gem command that uses SOCKS proxy:
Install socksify with gem install socksify (you'll need to be able to do this step without proxy, at least)
Copy your existing gem exe
cp $(command which gem) /usr/local/bin/proxy_gem
Open it in your favourite editor and add this at the top (after the shebang)
require 'socksify'
if ENV['SOCKS_PROXY']
require 'socksify'
host, port = ENV['SOCKS_PROXY'].split(':')
TCPSocket.socks_server = host || 'localhost'
TCPSocket.socks_port = port.to_i || 1080
end
Set up your tunnel
ssh -D 8123 -f -C -q -N user#proxy
Run your gem command with proxy_gem
SOCKS_PROXY=localhost:8123 proxy_gem push mygem

Related

How to install wkhtmltopdf for docker

I'm using wkhtmltopdf for nodejs, followed instructions for windows installation (and added it to PATH after installation). When i start my app through bash, it works just fine as it should. I manage to convert html to pdf.
But it doesnt work when im using docker, like it doesnt even exists. Im assuming there is some other way to install it for docker, or some way to add PATH to docker?? Any other ideas? hints?
And before u say it, been googling it and looking for images and installations for docker, none helped. Got one that u know it works?
Anyways for all the others that found themselves in the same pickle... I was trying to use wkhtmltopdf within docker container while wkhtmltopdf was only installed and executable within system (windows/linux) environment and not in the actual docker environment... after updating dockerfile to automatically install wkhtml with the build, I also had to SET THE PATH.. for linux docker smth like this
cp wkhtmltox/bin/* /usr/local/bin/ &&
that made everything works just as it should.

docker install with tcp enabled 0.0.0.0

Wondering if anyone knows how to install with tcp enabled? Something like below? I
yum install docker --tcp-enabled --host 0.0.0.0
I understand I can go and manual change OPTIONS in /etc/sysconfig/docker.
I am trying to provision a server with a fresh docker install through scripts and I do not want to log onto the box and make these changes, everytime a new version comes out. I also understand I can just use a script with sed/awk to do this, But just wondering if easier way, without having to maintain a script.
My preferred solution is to use /etc/docker/daemon.json. This will let you add options to just about any install.
Note that I don't believe this will unset options that were defined on the command line, it's designed to let you use both. Those command line options are defined by your startup script, which from your description is systemd on a RedHat/CentOS environment with /etc/sysconfig/docker injected environment variables (you won't see this on other platforms like Debian). So if you need to remove an option, you'll still need to update your /etc/sysconfig/docker.

Bundle commands not working due to proxy settings

I have a rails application that I set to use a proxy so that I could update gems in my school's LAN.
However now that I'm not using the school's network, when I do
bundle install
I get this error
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/home/me/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/uri/generic.rb:214:in `initialize': the scheme http does not accept registry part: cavs#students:cavsuon#proxy.uonbi.ac.ke:80 (or bad hostname?) (URI::InvalidURIError)
When I also do
gem update bundler
or
gem update --system
I get this error
ERROR: While executing gem ... (URI::InvalidURIError)
the scheme https does not accept registry part: cavs#students:cavsuon#proxy.uonbi.ac.ke:80 (or bad hostname?
I cannot recall how I set up my app to use proxy but even when I did it has never worked so I thought that it was never using a proxy in the first place.
How can I unset this proxy configuration and set it again if I'm on my school's network
Upon doing
echo $http_proxy
as suggested, I get
http://cavs#students:cavsuon#proxy.uonbi.ac.ke:80
How do I unset $http_proxy
By default it may be picking up the http_proxy environment variable.
Try running
echo $http_proxy
on the command line to see what it gives back to you. You can set that value using
export http_proxy=http://user:password#host:port
If that doesn't work, also see what HTTP_PROXY is set to.
You can unset a variable temporarily by using unset http_proxy. If it is something you need to change more permanently (i.e. it is there every time you open a terminal) you will need to check the various hidden files in your home directory (i.e. .profile or .bashrc) to find and remove it.
I had similar problem which turned out to be the problem in Ruby itself:
The problem is related to the uri component of Ruby itself, which
tries to match the userinfo part of the URI
So, in your case, according to this regexp doesn't accept # character and you should modify your /usr/lib/ruby/1.8/uri/common.rb:
-ret[:USERINFO] = userinfo = "(?:[#{unreserved};:&=+$,]|#{escaped})*"
+ret[:USERINFO] = userinfo = "(?:[#{unreserved};:&=+$,#]|#{escaped})*"
run export http_proxy=http://x.x.x.x:8080 on the command line and then check if that has changed using echo $http_proxy. This worked for me on 12/18/2018

rails s command does not run from ssh

I am using Putty to connect to my localhost, and I don't have any problems apparently, however, when I run command rails s to start my rails 4.0.0 application from Putty, it gives me this message:
jose#jose-laptop:~/rails/dedicated-agenda$ rails s
The program 'rails' can be found in the following packages:
ruby-railties-3.2
ruby-railties-4.0
Try: sudo apt-get install
I don't get that message from the terminal though, the application starts running just fine.
I had to reinstall ubuntu so I upgraded to ubuntu 14.04 just in case you need to know.
I don't know if I am missing something in my ssh settings or how could I use rails s from Putty.
Thanks in advance.
Your PATH environment variable is set differently when you are executing programs in an interactive shell and by ssh(using putty).
Use absolute path of the program to not depend on the PATH variable.
You can also set the right PATH variable at ~/.profile file and load the updated variables using the command source ~/.profile.
Now, you should be able to run the command.
You can use the command
>which rails
to see where rails is installed on your working session.
Then you need to make sure that is in your path when you ssh in.
If you are ssh'ing in as a different use then that user may not have permission to see the rails executable.

Rails: Why "sudo" command is not recognized?

In my application directory (on Windows) I run:
sudo pdfkit --install-wkhtmltopdf
as explained here, but I got this error:
'sudo' is not recognized as an internal or external command,
operable program or batch file.
What could be the problem ?
Sudo is a Unix specific command designed to allow a user to carry out administrative tasks with the appropriate permissions.
Windows does not have (need?) this.
Run the command with the sudo removed from the start.
sudo is a Unix/Linux command. It's not available in Windows.
sudo is used for Linux. It looks like you are running this in Windows.
That you are running Windows. Read:
http://en.wikipedia.org/wiki/Sudo
It basically allows you to execute an application with elevated privileges. If you want to achieve a similar effect under Windows, open an administrative prompt and execute your command from there. Under Vista, this is easily done by opening the shortcut while holding Ctrl+Shift at the same time.
That being said, it might very well be possible that your account already has sufficient privileges, depending on how your OS is setup, and the Windows version used.
sudo is a command for Linux so it cant be used in windows so you will get that error
Sudo is a Unix specific command designed to allow a user to carry out administrative tasks with the appropriate permissions.
Windows doesn't not have (need?) this.
Yes, windows don't have sudo on its terminal. Try using pip instead.
Install pip using the steps here.
type pip install [package name] on the terminal. In this case, it may be pdfkit or wkhtmltopdf.
Analogue to sudo in Windows is running command prompt "As Administrator" by right-clicking on it's link. Then everything you run in it will be "sudo-ed".
sudo is not for windows, its for unix/linux.
option 1: install ubuntu cli software (not OS) in windows, here is the windows store link: https://www.microsoft.com/en-in/p/ubuntu-2004/9n6svws3rx71. After installing you can use ubuntu's cli in your windows where sudo will work.
option 2: install and use gem (ruby on rails) for installing wkhtmltopdf-binary
gem install pdfkit
gem install wkhtmltopdf-binary
ref: https://github.com/pdfkit/pdfkit
option 3: you can use npm or python for wkhtmltopdf insted of ruby on rails, both modules (nodeJS python) works fluently and compatible with windows:-
https://www.npmjs.com/package/wkhtmltopdf
https://pypi.org/project/wkhtmltopdf/

Resources