简体   繁体   中英

'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. Both server has pretty much the same setup. But for for some reason. I can access console on production server with rails c produciton . But when I try to access console on staging server using 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.
  • the gemset that the application use is there.
  • the application is running fine . Just can't access console with 'rails c'

But for some reason, I can't access console with rails c . Any idea how to solve this issue?

I guess you didn't install rails globally. First, check your rails version you are currently using by bundle exec rails -v . Then, install rails globally by gem install rails -v <version> . This should solve your issue.

Run bundle install only makes rails available inside bundler. In most cases, this should be enough, because bundler helps prevent headaches of version conflicts.

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?

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. The application should run fine because it uses the gems that the Gemfile.lock has listed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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