Sam
Sam

Reputation: 1253

Bundler "Could not find rake" "in any of the sources"

I have a rake task with a namespace encompassing two tasks, start and stop. I namespace:stopped, then namespace:started again, and then ... bundler blew up at me:

/home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:87:in `block in materialize': Could not find rake-12.0.0 in any of the sources (Bundler::GemNotFound)
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:80:in `map!'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:80:in `materialize'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/definition.rb:176:in `specs'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/definition.rb:235:in `specs_for'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/definition.rb:224:in `requested_specs'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:118:in `block in definition_method'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:19:in `setup'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler.rb:100:in `setup'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/setup.rb:20:in `<top (required)>'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

bundle install works, rake, version 12.0.0 is installed, rails c starts up fine. And Passenger with Apache displays the app without issue. I've re-installed rvm, Ruby, Rails, etc. bundle exec rake namespace:start and bin\rake namespace:start raise the same error message.

I've posted this as a bug in bundler (with environment details), but maybe its not a bug, but a configuration issue with paths, permissions, or ... something?

Upvotes: 1

Views: 6277

Answers (2)

Sam
Sam

Reputation: 1253

I have finally realized my very silly mistake. Hopefully my embarrassment can save someone else's. I have followed some advice to fix an issue with the gem mini_magick around being unable to resize images that looks a bit like this:

$ cat config/environments/production.rb
# ...
ENV['PATH'] = "/usr/bin:#{ENV['PATH']}"

I finally realized that causes this weird situation:

$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
$ irb
2.4.0 :001 > `ruby -v`
 => "ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]\n"
2.4.0 :001 > quit
$ rails c production
Loading production environment (Rails 5.0.1)
2.4.0 :001 > `ruby -v`
 => "ruby 2.0.0p648 (2015-12-16) [x86_64-linux]\n"

As you can see, Rails is picking up a different version of Ruby -- indeed, the system Ruby, and not my RVM-managed Ruby 2.4.

For reference, a fix to the mini_magick issues that does not cause Rails to pick up the wrong Ruby version is to symlink mogrify (and not add the line to production.rb):

$ sudo ln -s /usr/bin/mogrify /usr/local/bin/mogrify

(Largely reposted from my GitHub issue response.)

Upvotes: 1

Chad K
Chad K

Reputation: 184

Be sure to invoke rake via bundler in the directory where your Gemfile is:

bundle exec rake namespace:start

It will ensure the gems in your bundle are available.

Upvotes: 1

Related Questions