2

When running spring directly (without bundle exec) from the command line, nothing happens! Only when running bundle exec spring, it works:

$ spring status
$ bundle exec spring status
Spring is running:

21990 spring server | synaesthesia | started 1 min ago 
22046 spring app    | synaesthesia | started 43 secs ago | test mode    

My bin/spring binstub looks like this:

#!/usr/bin/env ruby

# This file loads spring without using Bundler, in order to be fast
# It gets overwritten when you run the `spring binstub` command

unless defined?(Spring)
  require "rubygems"
  require "bundler"

  if match = Bundler.default_lockfile.read.match(/^GEM$.*?^    spring \((.*?)\)$.*?^$/m)
    ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR)
    ENV["GEM_HOME"] = ""
    Gem.paths = ENV

    gem "spring", match[1]
    require "spring/binstub"
  end
end

It has been patched by spring doing a bundle exec spring binstub --all. So I guess everything's configured correct? So why do I need a bundle exec all the time?

I'm using Rails 4.0.4.

Baldrick
  • 23,882
  • 6
  • 74
  • 79
Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152

1 Answers1

0

Turned out I used a specific branch on github, so the REGEX created by spring in the bin/spring executable didn't match:

  if match = Bundler.default_lockfile.read.match(/^GEM$.*?^    spring \((.*?)\)$.*?^$/m)

I changed the line to the following:

if match = Bundler.default_lockfile.read.match(/^GEM|GIT$.?^ spring ((.?))$.*?^$/m)

Now it works. It's pretty strange though that there isn't at least some error thrown when the regex doesn't match?!

Update

I added an issue about this on the GitHub Spring project: https://github.com/rails/spring/issues/277

Joshua Muheim
  • 12,617
  • 9
  • 76
  • 152