生产环境rails console spring自动启动的问题

在生产环境执行rails console没反应无法进入控制台,或者执行rails console的时候spring自动启动,导致所有的类名都无法识别,报错:NameError: uninitialized constant ClassName 。

快速解决方式:

# 加上 DISABLE_SPRING=true 参数
RAILS_ENV=production DISABLE_SPRING=true bundle exec rails c
# 或者先停掉spring
spring stop
RAILS_ENV=production bundle exec rails c


正常流程:

1. 在Gemfile中指定group :development

group :development do
  gem 'spring'
end

2. 执行bundle install

使用:
RAILS_ENV=production bundle install --without deveopment test

不要使用:
RAILS_ENV=production bundle install

3.查看spring是否启动

ps aux | grep spring

 

如果不幸spring已经被安装在生产环境,重新bundle install是无效的

1. 查看gem包安装位置

cat .bundle/config #如果找不到该文件表示装在全局

2. 删掉 BUNDLE_PATH 指定的文件

3. 删掉Gemfile.lock

4. 重新执行:

RAILS_ENV=production bundle install --without deveopment test

 

posted @ 2018-06-28 14:29  小芬喵  阅读(186)  评论(0编辑  收藏  举报