简体   繁体   English

'rails c'不起作用,但'bundle exec rails console'可以

[英]'rails c' doesn't work, but 'bundle exec rails console' does

I'm setting up the staging and production server on Ubuntu, deploy with Capistrano. 我正在Ubuntu上设置登台和生产服务器,使用Capistrano进行部署。 Both server has pretty much the same setup. 两个服务器都具有相同的设置。 But for for some reason. 但出于某种原因。 I can access console on production server with rails c produciton . 我可以使用rails c produciton访问生产服务器上的控制台。 But when I try to access console on staging server using rails c staging 但是当我尝试使用rails c staging访问登台服务器上的控制台时

The program 'rails' can be found in the following packages:
 * ruby-railties-3.2
 * ruby-railties-4.0
Try: sudo apt-get install <selected package>

The only way to access console on my staging server is to do 在我的登台服务器上访问控制台的唯一方法就是这样做

bundle exec rails console staging

On staging 在分期

  • the rvm seems to be correct, I can see the ruby version I'm using. rvm似乎是正确的,我可以看到我正在使用的ruby版本。
  • the gemset that the application use is there. 应用程序使用的gemset就在那里。
  • the application is running fine . 应用程序运行正常 Just can't access console with 'rails c' 只是无法通过'rails c'访问控制台

But for some reason, I can't access console with rails c . 但由于某种原因,我无法使用rails c访问控制台。 Any idea how to solve this issue? 不知道如何解决这个问题?

I guess you didn't install rails globally. 我猜你没有全局安装rails。 First, check your rails version you are currently using by bundle exec rails -v . 首先,通过bundle exec rails -v检查您当前使用的rails版本。 Then, install rails globally by gem install rails -v <version> . 然后,通过gem install rails -v <version>全局gem install rails -v <version> This should solve your issue. 这应该可以解决您的问题。

Run bundle install only makes rails available inside bundler. 运行bundle install仅在捆绑器内提供导轨。 In most cases, this should be enough, because bundler helps prevent headaches of version conflicts. 在大多数情况下,这应该足够了,因为bundler有助于防止版本冲突的麻烦。

A couple of questions to understand better the situation... 几个问题,以更好地了解情况......

Have you tried running bundle install for the current ruby version set on rvm for that application on that server? 您是否尝试在该服务器上为该应用程序的rvm上运行当前ruby版本的bundle install

Have you updated the gems for another application/branch? 你有更新另一个应用程序/分支的宝石? sometimes that happens because the rails c command uses the latest gems available and bundle exec... locates and uses the gems tied to the Gemfile.lock. 有时会发生这种情况,因为rails c命令使用最新的gem和bundle exec...定位并使用绑定到Gemfile.lock的gem。 The application should run fine because it uses the gems that the Gemfile.lock has listed. 应用程序运行正常,因为它使用Gemfile.lock列出的gem。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM