I can execute rails
-commands in production (FreeBSD 10) as long as Spring is disabled:
# DISABLE_SPRING=1 bin/rails runner -e production 'p "test"'
"test"
# script/rails runner -e production 'p "test"'
"test"
With Spring, the rails
-command fails with the following error:
# bin/rails runner -e production 'p "test"'
/usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:20:in `initialize': Connection refused - "/tmp/spring/6e31dd16c1146fc209ac385f36aac9a1" (Errno::ECONNREFUSED)
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:20:in `open'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:20:in `server'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `verify_server_version'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:25:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/rails.rb:23:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /s/usr-local/www/the_project/releases/20140724133941/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
So far, I verified that the according files in /tmp/spring
exist as expected.
What could be the cause of this error and how can I achieve a correctly working Spring?
UPDATE 1
Here is an outline of several checks I did so far.
# ls -al /tmp/spring
total 32
drwxr-xr-x 2 proj wheel 8 Jul 27 19:35 .
drwxrwxrwt 36 root wheel 43 Jul 28 08:22 ..
srwxr-xr-x 1 proj wheel 0 Jul 27 19:35 3004493e4fa38d91e78f82a2e74b4bc8
-rw-r--r-- 1 proj wheel 6 Jul 27 19:35 3004493e4fa38d91e78f82a2e74b4bc8.pid
srwxr-xr-x 1 proj wheel 0 Jun 30 13:00 383a7b299457953fc0eda45a4eca65f8
-rw-r--r-- 1 proj wheel 5 Jun 30 13:00 383a7b299457953fc0eda45a4eca65f8.pid
srwxr-xr-x 1 proj wheel 0 Jul 24 14:01 6e31dd16c1146fc209ac385f36aac9a1
-rw-r--r-- 1 proj wheel 6 Jul 24 14:01 6e31dd16c1146fc209ac385f36aac9a1.pid
# groups proj
proj wheel rvm
# bin/spring status
Spring is running:
25240 ruby: spring server | 20140727193408 | started 14 hours ago (ruby)
25245 ruby: spring app | 20140727193408 | started 0 secs ago | production mode (ruby)
# fuser /tmp/spring/*
/tmp/spring/3004493e4fa38d91e78f82a2e74b4bc8:
/tmp/spring/3004493e4fa38d91e78f82a2e74b4bc8.pid: 25240wa
/tmp/spring/383a7b299457953fc0eda45a4eca65f8:
/tmp/spring/383a7b299457953fc0eda45a4eca65f8.pid:
/tmp/spring/6e31dd16c1146fc209ac385f36aac9a1:
/tmp/spring/6e31dd16c1146fc209ac385f36aac9a1.pid: 17260wa
# ps aux | grep -E '25240|17260'
proj 17260 0.0 0.1 79040 3544 - IJ Thu02PM 0:00.47 ruby: spring server | 20140724133941 | started 92 hours ago (ruby)
proj 25240 0.0 0.1 79040 3372 - IJ 7:35PM 0:00.28 ruby: spring server | 20140727193408 | started 14 hours ago (ruby)
# head -n1 /tmp/spring.log
[2014-07-28 10:16:40 +0000] [66008] [server] started on /tmp/spring/3004493e4fa38d91e78f82a2e74b4bc8
# tail /tmp/spring.log
[2014-07-28 10:18:00 +0000] [66008] [server] accepted client
[2014-07-28 10:18:00 +0000] [66008] [server] running command rails_runner
[2014-07-28 10:18:00 +0000] [66128] [application:production] got client
[2014-07-28 10:18:00 +0000] [66128] [application:production] forked 66370
[2014-07-28 10:18:00 +0000] [66008] [application_manager:production] got worker pid 66370
[2014-07-28 10:18:03 +0000] [66128] [application:production] 66370 exited with 0
I was able to resolve the problem by changing the users login shell to bash (before, it was set to zsh) and adding this PATH to ~/.profile: PATH=$GEM_HOME/bin:$GEM_HOME/wrappers:$PATH
To ensure only RVM's ruby is being used, I also forcefully removed the system ruby (1.9.3): pkg remove -f ruby
(Note: Without the PATH setting mentioned above, this now causes the expected error env: ruby: No such file or directory
)
It appears a killall ruby
was necessary in order for the changes to take effect.
Maybe a bin/spring stop
would've been sufficient too.