2

I've just installed a fresh Ruby on Rails dev stack on my new Macbook, which runs Mac OS X 10.9 Mavericks.

Here is my stack:

  • Xcode command line tools
  • Homebrew
  • Rbenv
  • Bundler
  • Ruby 2.1.0
  • Rails 4.1.1

I ran rails new test_app to generate a first test app. This command successfully completed, but since it, every Rails command I try in my CLI returns this kind of error message:

$ test_app > bin/rails server

/Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load': no implicit conversion of nil into String (TypeError)
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/me/Documents/[PERSONNEL]/dev/test_app/bin/spring:16:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

Same error while trying to start a console:

$ test_app > bin/rails c

/Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load': no implicit conversion of nil into String (TypeError)
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `block in load'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/me/.rbenv/versions/2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

The bin/rake are working partially (I can use bin/rake routes but migrations are not working).

My last try was to install XCode, but it didn't solve it.


UPDATE: the command bundle exec rake rails:update:bin as mentioned bellow solve the problem for project, but needed to be executed on every new problem. The problem seems to be deeper.

Arenzel
  • 1,156
  • 1
  • 11
  • 18

2 Answers2

6

OK I found solution.

I've cleaned my mac too. and I got same error.

rails_root/bin folder is not there?

Try below

bundle exec rake rails:update:bin

kntmrkm
  • 171
  • 1
  • 2
1

I have the same problem. Short exploration follows below.

First of all, I have [] in the root path for my application. The error during rails s command

psylone@wizard:~/ruby-rails[code]/context$ rails s
/home/psylone/.rvm/gems/ruby-2.2.0/gems/spring-1.2.0/lib/spring/client/rails.rb:30:in `load': no implicit conversion of nil into String (TypeError)

is in spring gem here: https://github.com/rails/spring/blob/master/lib/spring/client/rails.rb#L27

That's because if Dir.glob contains [] in the path argument the result will be an empty array. So it's necessary to escape [] in the path argument for Dir.glob method. I think about something like this:

# Instead of line 27 in spring/client/rails.rb
require 'shellwords'
path = Shellwords.escape(Spring.application_root_path) << "/{bin,script}/rails"
load path

After this fix I've found rails s command works fine. But rails c command still causes an error. Probably the answer has the same nature.

So, the simplest way to avoid this error - rename the root path for your application (without [] characters).

Psylone
  • 2,788
  • 1
  • 18
  • 15
  • Thanks for investigating! I don't have the problem any more, so I can't validate your solution. Really appreciate your share however. :) – Arenzel Jan 13 '15 at 10:05