Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在生产模式下迁移时遇到的问题_Ruby On Rails_Ruby_Ruby On Rails 3_Ruby On Rails 3.1_Capistrano - Fatal编程技术网

Ruby on rails 在生产模式下迁移时遇到的问题

Ruby on rails 在生产模式下迁移时遇到的问题,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.1,capistrano,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.1,Capistrano,我正在使用RubyonRails3.1.0和CapistranoGem,我创建了一个迁移文件来更改数据库表的列名。在本地机器中,我在开发模式下运行rakedb:migrate命令,它可以工作,但我希望在生产模式下在远程服务器上使这些更改生效。我的问题是:如果运行Capistrano命令cap deploy:migrate,则在远程服务器上的生产日志文件中会收到以下错误消息: @Simone Carletti的更新 在deploy.rb文件顶部添加require'bundler/capistran

我正在使用RubyonRails3.1.0和CapistranoGem,我创建了一个迁移文件来更改数据库表的列名。在本地机器中,我在开发模式下运行rakedb:migrate命令,它可以工作,但我希望在生产模式下在远程服务器上使这些更改生效。我的问题是:如果运行Capistrano命令cap deploy:migrate,则在远程服务器上的生产日志文件中会收到以下错误消息:

@Simone Carletti的更新

在deploy.rb文件顶部添加require'bundler/capistrano'并运行cap deploy:migrations命令后,出现以下错误:

...
* executing "cd /<my_application_path>/releases/20111026132212 && bundle install --gemfile /<my_application_path>/releases/20111026132212/Gemfile --path /<my_application_path>/shared/bundle --deployment --quiet --without development test"
  servers: ["<my_remote_server_IP>"]
  [<my_remote_server_IP>] executing command
** [out :: <my_remote_server_IP>] Some gems seem to be missing from your vendor/cache directory.
** [out :: <my_remote_server_IP>] Could not find libv8-3.3.10.2 in any of the sources
   command finished in 2554ms
failed: "sh -c 'cd /<my_application_path>/releases/20111026132212 && bundle install --gemfile /<my_application_path>/releases/20111026132212/Gemfile --path /<my_application_path>/shared/bundle --deployment --quiet --without development test'" on <my_remote_server_IP>
注意:cap deploy:migrations命令创建了一个空的//shared/bundle/ruby/1.9.1目录,其中包含一个755 pemission

rake RAILS_ENV=production  db:migrate
你应该跑

bundle exec rake RAILS_ENV=production  db:migrate
确保在deploy.rb文件中包含bundler/capistrano配方


这些配方将为您更改命令。看。

你试过了吗;bundle exec rake db:migrate RAILS\u ENV=production@apneadiving-你确定这是肯定的吗?在过去,我运行一些从bundle exec开始的程序。。。我遇到了一些我不记得的严重问题…bundle exec只是用来执行rails应用程序中的rake版本,它解决了一些兼容性问题。@apReading-我更新了这个问题。为了确定,我应该在deploy.rb文件的顶部添加require bundler/capistrano吗?是的,没错,或者就在任何使用rake的自定义配方之前。我用部署应用程序时遇到的新错误更新了问题。你有解决新问题的方法吗?解决起来并不是那么简单。它需要在服务器端进行调试。对不起,这不是一个简单的问题->回答问题。这是原来的一个,事实上我给你提供了解决方案。我鼓励您深入了解Bundler的内部结构,并检查它失败的原因。
------------------------------------------------------------
cap bundle:install
------------------------------------------------------------
Install the current Bundler environment. By default, gems will be installed to
the shared/bundle path. Gems in the development and test group will not be
installed. The install command is executed with the --deployment and --quiet
flags. If the bundle cmd cannot be found then you can override the bundle_cmd
variable to specifiy which one it should use.

You can override any of these defaults by setting the variables shown below.

N.B. bundle_roles must be defined before you require 'bundler/capistrano' in
your deploy.rb file.

  set :bundle_gemfile,  "Gemfile"
  set :bundle_dir,      File.join(fetch(:shared_path), 'bundle')
  set :bundle_flags,    "--deployment --quiet"
  set :bundle_without,  [:development, :test]
  set :bundle_cmd,      "bundle" # e.g. "/opt/ruby/bin/bundle"
  set :bundle_roles,    {:except => {:no_release => true}} # e.g. [:app, :batch]
rake RAILS_ENV=production  db:migrate
bundle exec rake RAILS_ENV=production  db:migrate
require 'bundler/capistrano'