Rails runner without spring
This happens because you are using the spring
gem and your bin
folder has been "springified".
If you take a look in the bin/rails
file you will see that spring
is loaded before moving on with running whatever you requested from it.
You could "un-springify" your bin folder by running
bin/spring binstub --remove --all
This would mean of course that you opt out from all performance benefits that spring provides you. This should be OK for production environments. In fact, it is recommended that you do not install spring in your production environments [1].
So I suggest that you modify your Gemfile
and place spring
under the development
group. In production you usually do something like:
bundle install --without development test
That way spring will never make it to your production servers. See also this related issue on Github.
--
1 . Spring project readme file
How can I run the Ruby on Rails console in production without executing Spring?
I found it. You need to set the environment variable DISABLE_SPRING
to true when executing the console, like this:
DISABLE_SPRING=true rails console
That way the Spring server will not load.
To do this automatically, you can export this variable in your .bashrc
, .tcshrc
, .zshrc
appending this code to it:
export DISABLE_SPRING=true
and then loading it, in my case (I'm using zsh):
source ~/.zshrc
Reference:
https://github.com/rails/spring
http://www.cyberciti.biz/faq/linux-unix-shell-export-command/
Rails task not running unless rails runner has been executed in the command prompt since the linux server machine's bootup
I found the problem. It has to do with spring, essentially the environment is set up to try to run with spring, but it doesn't automatically start the processes. Adding DISABLE_SPRING=1 seems to fix the issue.
class Admin::AccessLogManageController < Admin::AdminController
def update_project_ids
command = "DISABLE_SPRING=1 rbenv exec bundle exec rails runner --environment=#{Rails.env} Tasks::UpdateAccessLogProjectIds.execute"
pid =spawn(command, :chdir=>".")
Process.detach(pid)
end
end
This had the information I needed to solve the problem.
Rails runner without spring
How to fix 'spring is not part of the bundle' when trying to run rails console in production
You probably need to add Spring to the Gemfile.
Can you show your Gemfile?
If you have something like
group :development do
gem 'spring'
You can promote it above the block.
Spring stopping Rails console from running
This appears to be some strange issue with the binding_of_caller
in conjunction with Spring. Removing that gem got things back working as expected. I knew I'd find the answer as soon as I asked.
There isn't currently a fix, but it does seem to have an open issue already:
https://github.com/charliesome/better_errors/issues/411
How to resolve Connection refused when executing bin/rails (spring) commands?
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.
Related Topics
How to Share Worker Among Two Different Applications on Heroku
Get All Local Variables or Available Methods from Irb
Load Works on Local Path, Require Doesn'T
Terminal Not Executing Ruby Files
Compute Geo Distance in Elasticsearch
How to Trigger Mouse Event in Capybara Test
Testing Rake Task with Rspec with Rails Environment
Require File Without Executing Code
How to Break Out of a Map/Collect and Return Whatever Has Been Collected Up to That Point
How to Create a Rails 3 Route That Will Match All Requests and Direct to One Resource/Page
Getting Remove_Entry_Secure Error While Using Ruby Application
Argument Out of Range Rails 4 and Bootstrap3-Datetimepicker-Rails
Can Multiple Sidekiq Instances Process The Same Queue
Rubymine Error: Unable to Run Gem 'Rails'. Cannot Find 'Rails'
How to Ensure a Rake Task Only Running a Process at a Time
Why Does Array#Each Return an Array with The Same Elements
Set Compression Level When Generating a Zip File Using Rubyzip