ruby-on-rails - 致命 : could not read Username for 'https://github.com' : No such device or address

标签 ruby-on-rails deployment github capistrano

几周以来,我一直在使用 github 和 capistrano 将我的 Rails 4 应用程序部署到 Rackspace。一切都很好,直到我最终将我的存储库设为私有(private)。现在,我在运行“cap deploy”后收到以下错误:

“致命:无法读取‘https://username@github.com’的密码:没有这样的设备或地址”

下面是我的 deploy.rb 文件中的代码

set :application, "appname"
set :repository,  "https://git_username@github.com/git_username/appname.git"
set :scm, :git
set :scm_username, "git_username"
set :scm_passphrase, "git_password"
set :scm_command, "git"
set :keep_releases, 5
set :branch, "master"
set :rails_env, "production"

set :deploy_to, "/var/www/doLocal"

set :user, "deployer"
set :password, "deployer_password"
set :use_sudo, false

ssh_options[:forward_agent] = true

server "/path/to/server", :app, :web, :db, :primary => true

after "deploy:restart", "deploy:cleanup"


namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end

我已经尝试过在 github 存储库名称中添加和不添加用户名。如果它存在,我会从上面收到密码错误,但如果它不存在,我会收到以下错误:

“致命:无法读取‘https://github.com’的用户名:没有这样的设备或地址”

知道问题是什么吗?我假设这与我更改为私有(private)存储库有关。我已经阅读了一些关于使用 ssh 的内容,但也没有阅读。

任何建议或帮助将不胜感激!

最佳答案

所以,我想通了。为了使用 Github 上的私有(private)仓库使用 https 进行部署,您需要使用 Github 的 OAuth API。在您的 github 帐户上的 Edit Profile 下,单击 applications,然后生成 OAuth Token。然后,将您的 token 添加到您的 repo url,如下所示:

 set :repository,  "https://<OAuthToken>@github.com/username/application.git"

之后,我能够运行
 cap deploy

并将我的应用程序部署到我的远程服务器。

关于ruby-on-rails - 致命 : could not read Username for 'https://github.com' : No such device or address,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18886729/

相关文章:

jquery - 样式 image_tag 和光滑的轮播?

ruby-on-rails - 如何使用 ruby​​ 在两个新行上拆分文本

ruby-on-rails - 确保管理员帐户不可删除

ruby-on-rails - 在新的 Rails 项目中从 SQLite 更改为 PostgreSQL

java - 部署 JBoss EAP 6.4.0 时找不到standalone.xml 中提供的(远程)主机名

deployment - PhpStorm 部署未上传 Composer 的供应商文件夹内容

linux - 如何使用受密码保护的私钥执行 salt 状态 git.latest

java - EL 在 glassfish 上的部署问题

git - 将本地新 Git 仓库作为分支推送到现有的远程仓库?

git - 如何恢复git历史记录