Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use system rake with a bundled rails app #159

Open
myronmarston opened this issue Jan 6, 2010 · 17 comments
Open

Can't use system rake with a bundled rails app #159

myronmarston opened this issue Jan 6, 2010 · 17 comments

Comments

@myronmarston
Copy link

I've just converted a Rails 2.3.5 app from the old config.gem declarations to use bundler instead. One issue I've had is not being able to use system rake. Things seem to work if I use the bundled rake executable in bin, though.

I think the problem is that rake is a dependency of rails, and when I run a rake task that loads the rails environment, it in turn loads the bundler environment, which loads the bundled copy of rake even though it's already loaded.

I don't mind using ./bin/rake rather than rake, but that has it's own issues. (See this).

Anyhow, here's the stack trace I get when running system rake:

~/projects/dgnetwork% rake test:units --trace
(in /Users/myron/projects/dgnetwork)
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems.rb:14: warning: already initialized constant VERSION
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems.rb:14: warning: already initialized constant RubyGemsVersion
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems.rb:194: warning: already initialized constant MUTEX
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems.rb:196: warning: already initialized constant RubyGemsPackageVersion
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems.rb:202: warning: already initialized constant WIN_PATTERNS
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems.rb:1079: warning: already initialized constant MARSHAL_SPEC_DIR
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems.rb:1084: warning: already initialized constant YAML_SPEC_DIR
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/version.rb:72: warning: already initialized constant VERSION_PATTERN
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:20: warning: already initialized constant OPS
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb:30: warning: already initialized constant OP_RE
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/version.rb:246: warning: already initialized constant Requirement
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:18: warning: already initialized constant TYPES
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/platform.rb:171: warning: already initialized constant RUBY
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/platform.rb:177: warning: already initialized constant CURRENT
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:39: warning: already initialized constant NONEXISTENT_SPECIFICATION_VERSION
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:50: warning: already initialized constant CURRENT_SPECIFICATION_VERSION
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:56: warning: already initialized constant SPECIFICATION_VERSION_HISTORY
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:72: warning: already initialized constant MARSHAL_FIELDS
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:75: warning: already initialized constant TODAY
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:593: warning: already initialized constant Cache
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:14: warning: already initialized constant DEFAULT_BACKTRACE
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:15: warning: already initialized constant DEFAULT_BENCHMARK
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:16: warning: already initialized constant DEFAULT_BULK_THRESHOLD
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:17: warning: already initialized constant DEFAULT_VERBOSITY
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:18: warning: already initialized constant DEFAULT_UPDATE_SOURCES
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:24: warning: already initialized constant OPERATING_SYSTEM_DEFAULTS
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:30: warning: already initialized constant PLATFORM_DEFAULTS
/Users/myron/.rvm/ruby-1.9.1-p376/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:53: warning: already initialized constant SYSTEM_WIDE_CONFIG_FILE
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:32: warning: already initialized constant RAKEVERSION
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS
WARNING: Possible conflict with Rake extension: String#ext already exists
WARNING: Possible conflict with Rake extension: String#pathmap already exists
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:404: warning: already initialized constant EMPTY_TASK_ARGS
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:452: warning: already initialized constant EMPTY
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:960: warning: already initialized constant RUBY_EXT
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:964: warning: already initialized constant RUBY
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1033: warning: already initialized constant LN_SUPPORTED
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1242: warning: already initialized constant ARRAY_METHODS
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1245: warning: already initialized constant MUST_DEFINE
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1249: warning: already initialized constant MUST_NOT_DEFINE
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1253: warning: already initialized constant SPECIAL_RETURN
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1259: warning: already initialized constant DELEGATING_METHODS
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1569: warning: already initialized constant DEFAULT_IGNORE_PATTERNS
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1575: warning: already initialized constant DEFAULT_IGNORE_PROCS
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1612: warning: already initialized constant FileList
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1638: warning: already initialized constant EARLY
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1968: warning: already initialized constant DEFAULT_RAKEFILES
rake aborted!
stack level too deep
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:1650:in `<=>'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:1650:in `<=>'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:1650:in `<=>'
... (the same thing another  8000 times) ...
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:1650:in `<=>'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1650:in `<=>'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/activesupport-2.3.5/lib/active_support/core_ext/time/calculations.rb:298:in `compare_with_coercion'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/testing.rake:57:in `>'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/testing.rake:57:in `block (3 levels) in <top (required)>'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1268:in `select'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1268:in `select'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/testing.rake:57:in `block (2 levels) in <top (required)>'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake/testtask.rb:91:in `initialize'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/testing.rake:55:in `new'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/testing.rake:55:in `block in <top (required)>'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1882:in `in_namespace'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:910:in `namespace'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/testing.rake:54:in `<top (required)>'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `block in load_with_new_constant_marking'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in `load_with_new_constant_marking'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/rails.rb:4:in `block in <top (required)>'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/rails.rb:4:in `each'
/Users/myron/projects/dgnetwork/vendor/bundler_gems/ruby/1.9.1/gems/rails-2.3.5/lib/tasks/rails.rb:4:in `<top (required)>'
/Users/myron/projects/dgnetwork/Rakefile:10:in `require'
/Users/myron/projects/dgnetwork/Rakefile:10:in `<top (required)>'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:2017:in `block in load_rakefile'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:2000:in `block in run'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/myron/.rvm/gems/ruby-1.9.1-p376/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
/Users/myron/.rvm/ruby-1.9.1-p376/bin/rake:22:in `load'
/Users/myron/.rvm/ruby-1.9.1-p376/bin/rake:22:in `<main>'
@merbjedi
Copy link

merbjedi commented Jan 9, 2010

I think it might work if you require your environment file ontop of Rakefile

something like this:

require File.join(File.dirname(__FILE__), "vendor", "gems", "environment")

@myronmarston
Copy link
Author

Thanks for the suggestion, but I tried it and it didn't work :(. I'm getting the same error.

@claudiob
Copy link

I had the same problem, due to the fact that I was using Ruby 1.9 (rather than 1.8), so I guess the problem comes from the multi-ruby enhancement introduced in bundler 0.8.0. As a matter of fact, I tried installing gem bundler version 0.7 (rather than 0.8) and the problem was solved

@stephankaag
Copy link

Same problem overhere

@aaronchi
Copy link

aaronchi commented Apr 2, 2010

same issue :(

@aaronchi
Copy link

aaronchi commented Apr 2, 2010

this works if using bundler 0.9.11

@dirkholzapfel
Copy link

same problem here. rails 3 beta2 came with bundler 0.9.14 - that brought the above mentioned problem. thanks for the tip of v0.9.11 - works.

@eet-nu
Copy link

eet-nu commented Apr 4, 2010

0.9.13 works for me. .14 and .15 don't

@speedmax
Copy link

This is a ruby 1.9 only issue

All new version of bundler up to 0.9.18 are broken on ruby 1.9.1 /1.9.2-dev when using system rake

Version that works are

0.9.13
0.9.11

Ah.. this is annoying

@mikesmullin
Copy link

something like this also happens to me when i bundle lock. was remedied with bundle unlock.

ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux]
Rails 3.0.0.beta3
Bundler version 0.9.24

@topherfangio
Copy link

Any updates on this? I am running bundler 0.9.25, ruby 1.9.2-head (1.9.3 trunk) and rails 3.0.0beta3. Any help would be greatly appreciated :-)

@topherfangio
Copy link

So, a small update: I deleted all gems installed with bundle by running the following in my project directory:

rm -rf ~/.bundle ; rm -rf .bundle

I then manually installed all of the gems using "gem install ..." instead of using bundle and everything appears to be working now. I hope they get this sorted out though, bundler is so much easier when it works :-)

@visoft
Copy link

visoft commented May 23, 2010

Thanks for the workaround @topherfangio. That was the only way I could get rake working for now with bundler 0.9.25 and ruby 1.9.1

@tatum
Copy link

tatum commented May 25, 2010

For what it's worth, I had the same problem. Deleted ".bundle" folders and re-installed through gem install and it works now.

ruby 1.9.3dev (2010-05-23 trunk 27967)
rails 3.0.0.beta3

@vidmantas
Copy link

If you've already installed gems using bundler then you can easily install them into system with one command from you project's vendor/bundler/cache:

 [sudo] gem install * --local

@toonsend
Copy link

Had the same problem I keep forgetting to use bundle exec. Try using,

bundle exec rake test:units

@mendable
Copy link

I had a similar problem using bundler 0.9.26. It was caused by one :git => ... sourced gem I was using having a "require 'rake'" in it's gemspec file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests