I've been using capistrano successfully for a while now and all of a sudden in every project I've lost the ability to deploy.
Environment:
os X (Mavericks)
ruby 1.9.3p194
rvm (locally, not on server)
rails 3.2 and up
RubyGems 1.8.25
I'm not using rsa_keys or anything I want capistrano to prompt for user and password. Suddenly it has decided not to ask for a password, but does ask for user. Then it rolls back and gives me the following error.
[deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: sub.example.com (Net::SSH::AuthenticationFailed: Authentication failed for user user#sub.example.com)
connection failed for: sub.example.com (Net::SSH::AuthenticationFailed: Authentication failed for user user#sub.example.com)
This has occurred on my personal laptop and my iMac at work. It occurs when deploying to two different servers (both linux)
I'm completely at a loss here. Any ideas?
Figured it out! Apparently this issue was with net-ssh gem. I had version 2.8.0 installed recently with some updates to my development environment and was the cause.
I'm not sure why it was failing, but gem uninstall net-ssh -v 2.8.0< fixed it for me.
If anyone actually knows why this was an issue or how I can correct this issue with the newer version of net-ssh I'd be interested to hear it.
The answer may break your rails app due to gem dependancies.
The issue is with net-ssh as was correctly answered by Sparkmasterflex, however whilst this will get capistrano working ok it may break your rails app:
These steps fixed both capistrano and rails for me ...
In your Gemfile add gem 'net-ssh', '2.7.0'
Run bundle update net-ssh
Run bundle (just to be sure everything is working ok'
Run gem uninstall net-ssh -v 2.8.0
If you are a rails user you should now be able to run both the rails server and capistrano.
I have a workaround that doesn't require downgrading net-ssh, per a comment at the link that Zach Lipton posted. Place this code in config/deploy.rb:
set :ssh_options, {
config: false
#Other options...
}
After I did that, I got another error, Error reading response length from authentication socket. Found the solution to that here. Execute these commands at your Bash prompt:
$ eval $(ssh-agent)
$ ssh-add
Upgrading your net-ssh version to 2.8.1 will solve the problem. They released a version bump in 19th february 2014 that fix this and other problems.
Uninstall your current net-ssh gem (gem install net-ssh -v 'version')
Just paste this on your Gemfile:
gem 'net-ssh', '~> 2.8.1', :git => "https://github.com/net-ssh/net-ssh"
Run bundle install
I had the same problem while deploying using capistrano
Net::SSH::AuthenticationFailed: Authentication failed for user deployer#IP
ssh-copy-id deployer#ip
This will add your keys to server and you can login without password.
set :ssh_options, {
verbose: :debug
}
... helps a lot!
I had an issue that I generated my public and private keys with puttygen and exported private key as OpenSSH with name <somename>.id_rsa. An then saved public key with name <somename>.id_rsa.pub.
( ! ) The public key puttygen saves is in RFC 4716 format not PEM. Use public suffix instead of pub for public key file-
This snippet works for me:
group :development do
#.....
gem 'capistrano', "~> 2.15"
gem "net-ssh", "~> 2.7.0"
#.....
end
First try to connect to your server with certificate (file.pem) with this command:
ssh -i "file.pem" user#yourServerIp
Then try to run cap production deploy. It solved error for me. I think it is because time limit for certificate expired.
If all the above solutions doesn't work,please restart your system as you might be facing the issue due to net-ssh host connections.when you restart and enter the deployment command ,it will ask to add the identity to known hosts.
Related
We currently host a gem (custom version of rubocop) in a private Github repo for one of our rails applications. In order to successfully bundle install that gem, bundler needs to have credentials with read permissions to that repo. We only use this gem for local development, and so the gem is listed under the development group in our project's Gemfile:
group :development do
...
source 'https://rubygems.pkg.github.com/<org>' do
gem '<custom-gem>'
end
end
Associated entry in Gemfile.lock
GEM
remote: https://rubygems.pkg.github.com/<org>/
specs:
<org>-rubocop (0.1.2)
rubocop (= 0.77.0)
rubocop-rails (= 2.4.0)
For production, we do not need this gem, however we encountered an error during the deploy phase where bundle is still asking for the credentials, even though the gem will not be in use.
This error may have manifested itself after upgrading bundler from 2.2.28 to 2.3.7, but we're not positive about that.
Is it possible to configure bundler to avoid making the authentication call for a gem that will not be in use? If we can avoid this authentication call, then we can avoid specifying sensitive credentials in our production environment, which would be a lot less work...Any bundler documentation or existing Github issue that answers this question would be greatly appreciated!
Other details:
Ruby 3.1.1
Rails 7.0.2.3
In production build, we are specifying the following command:
bundle config set --local without 'development test' && bundle install
Build Logs tipping us off to the issue:
Step #1 - "build-push": Authentication is required for rubygems.pkg.github.com.
Step #1 - "build-push": Please supply credentials for this source. You can do this by running:
Step #1 - "build-push": `bundle config set --global rubygems.pkg.github.com username:password`
Step #1 - "build-push": or by storing the credentials in the `BUNDLE_RUBYGEMS__PKG__GITHUB__COM`
If I had to guess, I think your command needs to be updated to have a colon-separated list of groups to skip.
From the Bundler Docs
without (BUNDLE_WITHOUT): A :-separated list of groups whose gems bundler should not install.
So try to update your command to the following and see what happens:
bundle config set --local without 'development:test' && bundle install
Not sure if this is an all-encompassing answer to the issue, but the following changes seem to resolve the problem. I'd love to hear from anyone who might have some thoughts that might explain why this solution works or thoughts disproving my hypothesis : )
Our Gemfile.lock had the following entry:
PLATFORMS
x86_64-darwin-21
Adding the following platform entry:
bundle lock --add-platform x86_64-linux
Results in a the Platforms entry to be updated to
PLATFORMS
x86_64-darwin-21
x86_64-linux
After this update, bundler seems to be respecting the gem groups and does not make an authentication request to the private repo hosting our custom gem.
Does anybody else spend more time wrestling with rails than actually coding with it??
Very new to rails and programming in general, so I apologize if this is a stupidly easy question. I don't know enough to understand what's wrong here.
I upgraded to ruby 2.2.2 and somehow lost rails in the process. I don't know why. Now every time I try to load it again, I get the following:
Could not find a valid gem 'rails' (>= 0) in any repository
I've tried sudo gem install rails and gem install rails to the same effect. I've already checked similar postings here, here, here, here, and here to no effect.
How can I fix this and move on?
Macbook pro 10.10.3
Ruby 2.2.2
Chases-MacBook-Pro:pinteresting Chase$ sudo gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
Chases-MacBook-Pro:pinteresting Chase$ gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
Chases-MacBook-Pro:pinteresting Chase$ bundle install
-bash: bundle: command not found
Chases-MacBook-Pro:pinteresting Chase$
edit
I'm behind a VPN, but that shouldn't make a difference because I've checked this several times and it has never been a problem for coding in the past. Since I live in China I have to use VPN a lot, but most of the coding sites are open.
Right now I'm systematically going through each solution and copying down the error messages.
Here's what happened when I did everything at this link
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
1) railsinstaller.org = the packages are out of date. Nothing over 10.6. Does that matter?
2)where ruby? = -bash where: command not found
3)rvm gem install rails = Please note thatrvm gem ...was removed, trygem install railsorrvm all do gem install railsinstead. ( see: 'rvm usage' )
4) gem install rails = could not find a valid gem 'rails' (>= 0) in any repository.
5) rvm all do gem install rails
= nothing. It just sat there and didn't seem to do anything.
6) curl -L https://get.rvm.io | bash -s stable --autolibs=enabled [--ruby] [--rails] [--trace]
= A bunch of information but no action. I opened to new terminal window 10 minutes ago and it still hasn't done anything.
7) curl -L https://get.rvm.io | bash -s stable --rails
= installs rvm and then ends with the same error could not find a valid gem for rails
8) gem sources -a https://rubygems.org = added the site to the sources... idk if that will change anything...
no change after following all the previous steps
Since I know rails is not on my computer and something might have changed since I did the steps above, I just set my VPN to a new setting and used sudo gem install rails. This appears to have installed rails and many gems, however...
I then ran rails -v and got the following error:
[!] There was an error parsingGemfile: no .<digit> floating literal anymore; put 0 before dot - gem 'rails', 3.2.11
^
/Users/Chase/Desktop/pinteresting/Gemfile:4: syntax error, unexpected tINTEGER, expecting '('. Bundler cannot continue.
# from /Users/Chase/Desktop/pinteresting/Gemfile:4
# -------------------------------------------
#
gem 'rails', 3.2.11
# gem 'sass-rails', '~> 5.0'
# -------------------------------------------`
I solved the same problem as follows:
gem source -a http://rubygems.org/
I think the reason is about https.
After trying all the steps I listed earlier, I connected to VPN through a new setting. The one I was using only routed the VPN through my browser, but the new one affects the entire internet connection. I think this is what finally allowed me to download rails again.
After downloading rails, it was just a matter of messing with the Gemfile to get everything downloaded, and voila!
I'm attempting to follow the Hartl Rails Tutorial, and having trouble with the bundler gem.
When using the commands 'bundle install' or 'bundle update' I get the following output:
Fetching source index from https://rubygems.org/
Could not fetch specs from https://rubygems.org/
I've searched for this output, but did not find many related issues online.
Maybe I have another gem that is interrupting bundler? I have little experience with rails at this point.
source 'https://rubygems.org'
gem 'rails', '3.2.12'
group :development do
gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
The solution for me was two parts: I changed https to http, and that temporarily solved the issue. The second issue was that I think I had a bad install of ruby 2.0.0 even though I was using a fresh install of ruby 1.9.3. So I reinstalled ruby 2.0.0, and I could use bundle install with https.
Just in case none of the above satisfies the next intrepid explorer, I thought I'd drop here that after I spent 4 hours on this doing variants of the search that landed me here, I finally discovering that IPV6 was the culprit, after finding this specific thread on help.rubygems.org. Solution? this (Fedora, Linux):
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
set up a shell script to flip IPV6 on and off so I could run a command without it, and now everything runs peachy.
I had the same issue. The only working solution I found was to force http instead of https in Gemfile:
source 'http://rubygems.org'
you can try the following, if in windows:
set HTTP_PROXY= <your proxy address without http://>
set HTTPS_PROXY=%HTTP_PROXY%
For eg:
HTTP_PROXY=mycompany.myproxy.com:8080
HTTPS_PROXY=%HTTP_PROXY%
Worked for me
It can be temporary network issue as well.
Try restarting network services using command
service network restart
If its *nix machine.
I had the same issue using ruby-2.0.0-p247 on OS X 10.8.5.
Make sure the first line in Gemfile is using https://
source 'https://rubygems.org'
I reinstalled that version of ruby.
rvm reinstall ruby-2.0.0
Ruby was upgraded ruby-2.0.0-p598 (version depends on latest patch).
bundle then worked without error although all the gems were reinstalled.
Mine was just a simple network issue, just restart pc / router
The other reason causing such that issues is the fact if you are behind proxy server. I describe here solution, maybe it will be usefull for someone else. :)
In case that you did not know Login/pass for yours proxy, and meet this issues you could firstly check if you need to (re)install anything, by command:
C:\...> bundle check
Resolving dependencies...
The Gemfile's dependencies are satisfied
If you get other respons then above, you could find properly gems in properly versions here (rubygems.org), then install it (from the directory with downloaded gem) by command:
gem install <gem-name> --locally
Use wget to see if you can reach the domain
wget http://rubygems.org/latest_specs.4.8.gz
If this fails then try the following.
Edit your /etc/resolv.conf file and add these lines near the top to use Google's name servers
nameserver 8.8.8.8
nameserver 8.8.4.4
I had this issue while working in Cloud 9. After trying several 'bundle install' and sending an email to c9 support(no reply) I was able to get it working by killing all the processes and doing a hard-restart of the IDE.
Do this by clicking directly on the little bar-graphs at the top of the right-hand side that show CPU, Memory, Disk. Then click on the process list, select them all, and force kill. Then exit out of the process list. Click on the bar-graphs again, and this time click 'Restart'.
After this I was able to run bundle with no problems.
Either with http or https did not work.
After I disabled the IP
v6, it worked
https://support.purevpn.com/how-to-disable-ipv6-linuxubuntu
Adding variable for proxy worked fine.
Additionally if you are using Bitnami redmine like me you can add that into setenv.bat then when you start command line with Bitnami Redmine short cut it will be automatically added to your environment.
You can find this under Bitnami installation folder.
If you are using Cloud9, just restart (command R) and try again
Sometimes it happens due to proxy you are using.
I tried to resolve this by using a connection without proxy and all worked perfectly fine.
Then try:
bundle update
And then go for
bundle install
For me, restarting the computer worked. I had already reinstalled ruby, updated bundler, removed 's' https:// but none of them worked!
A very simple solution I've used recently to overcome Bundler::HTTPError Could not fetch specs from https://rubygems.org/ which doesn't require you to disable IPV6 globally in your system:
ping -4 rubygems.org - to get an IPV4 address
Add the following line to your /etc/hosts file (use whatever IP address from the previous command output cause it might change):
151.101.129.227 rubygems.org
I just had to restart my wifi and it started working.
CHange your source form https to http after run
sudo bundle update
sudo bundle install
In my case the source of the problem was VPN. Disconnecting from it helped to resolve the issue.
I've recently been trying to work with Amazon EC2 to upload my first Rails project. In that process I vaguely remember configuring a key somewhere in the command line to let me connect to the EC2 instance. Anyway, since that (I think), I'm unable to install Ruby Gems as I get the error:
I've been looking for hours to try and fix this with no joy so any help would be greatly appreciated!
It seems your gem config is still looking at https://gemcutter.org.
Visiting this in your browser you will quickly realise the problem, the SSL certificate is signed for rubygems.org
I suggest you change your gem source to https://rubygems.org
Try setting the gem source
gem sources --add https://rubygems.org/
Now if you run
gem sources
you should get something like
*** CURRENT SOURCES ***
https://gemcutter.org/
https://rubygems.org/
So remove gemcutter.org too
gem sources --remove https://gemcutter.org/
Then you should be fine.
When I try to install gem like bundler or rake after creating new gemset , its not installing
,but if i intall old version its working fine for me . Here are the error logs while installing gems
gem install rake
Fetching: rake-0.9.2.2.gem ( 7%)ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
too many connection resets (http://cachefly.mirrors.rubygems.org/gems/rake-0.9.2.2.gem)
This problem was caused by the cachefly server.
It seems that the folks over at rubygems.org disabled this mirror and then people's downloads were able to continue successfully.
There is a thread over at rubygems.org discussing this issue.
Use DevKit to install gem separately .
Edit :
Please check if you curl or wget that URL:
wget http://production.cf.rubygems.org/gems/rails-2.3.8.gem
curl -O http://production.cf.rubygems.org/gems/rails-2.3.8.gem
If not, then the problem is with your internet connection, http proxy or
provider.
If your browser works, might be due an HTTP proxy.
I had a similar issue when Capistrano was running a bundle install on a remote server. It seems to have been caused by a .rvmrc file in the project that I had not authorised.
So all I had to do to fix is was ssh into the server, cd into the project and accept the .rvmrc config file.
got similar problem
gem install rails
# after 5 minutes
WARNING: Error fetching data: too many connection resets (http://production.s3.rubygems.org/latest_specs.4.8.gz)
gem install rails --source 'https://rubygems.org'
# after 5 minutes
WARNING: Error fetching data: too many connection resets (http://production.s3.rubygems.org/latest_specs.4.8.gz)
but when I create Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
and run bundle install it works
my location is London, UK
(also created topic on http://help.rubygems.org/discussions/problems/4494-too-many-connection-resets-when-gem-install-rails )
Always check if your computer isn't downloading because of administrator privileges (in cmd, shell, or rubymine).