small medium large xlarge

Generic-user-small
01 Sep 2011, 22:13
Wally Wedel (8 posts)

I just downloaded Agile Web Development 4th Edition P2. I installed Ruby 1.9.2 and Rails 3.1 using rvm as described in Chapter 1 and all went well apparently. The demo in Chapter 2 went as described.

However when I get to chapter 5 the rake db:migrate yields this result:

Superior:depot wmwedel$ rake db:migrate /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:9: warning: already initialized constant VERSION /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:26: warning: already initialized constant RAKEVERSION /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/early_time.rb:17: warning: already initialized constant EARLY /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:28: warning: already initialized constant DEFAULT_RAKEFILES WARNING: Possible conflict with Rake extension: String#ext already exists WARNING: Possible conflict with Rake extension: String#pathmap already exists /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/invocation_chain.rb:49: warning: already initialized constant EMPTY /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/dsl_definition.rb:143: warning: already initialized constant Commands /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:44: warning: already initialized constant ARRAY_METHODS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:47: warning: already initialized constant MUST_DEFINE /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:51: warning: already initialized constant MUST_NOT_DEFINE /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:55: warning: already initialized constant SPECIAL_RETURN /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:61: warning: already initialized constant DELEGATING_METHODS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:364: warning: already initialized constant DEFAULT_IGNORE_PATTERNS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:370: warning: already initialized constant DEFAULT_IGNORE_PROCS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:64: warning: already initialized constant FileList /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:65: warning: already initialized constant RakeFileUtils rake aborted! stack level too deep

(See full trace by running task with –trace) Superior:depot wmwedel$

Is this some kind of rake bug in Mac OS X Lion? I am running Mac OS X 7.1 Lion on an iMac.

Samr_small_pragsmall
02 Sep 2011, 01:20
Sam Ruby (634 posts)

I don’t believe that this is related to Lion; I have seen symptoms similar to these when I have had conflicting versions of some of the components installed; at least for me these problems went away when I used rvm to install a separate Ruby installation.

These symptoms seem very close to yours: http://stackoverflow.com/questions/7227017/rake-dbcreate-not-working

Try the solution listed there: http://stackoverflow.com/questions/7227017/rake-dbcreate-not-working/7228756#7228756

Generic-user-small
02 Sep 2011, 05:23
Geraud Puechaldou (3 posts)

Hello

If you look in the ‘gem list’ You see 2 rake installed

Then the solutIon given by Sam Ruby should worked

Regards

Generic-user-small
02 Sep 2011, 15:20
Wally Wedel (8 posts)

Thanks for your replies.

I do not see two rake installed when I do a gem list.

However the solution that Sam pointed to did correct the problem. Like the poster in the solution thread I am mystified by what caused the problem as the installs all seemed to proceed without reported problems.

Here is another shell log recording the problem and the solution:

Valmont:~ wmwedel$ gem list

** LOCAL GEMS **

actionmailer (3.1.0) actionpack (3.1.0) activemodel (3.1.0) activerecord (3.1.0) activeresource (3.1.0) activesupport (3.1.0) ansi (1.3.0) arel (2.2.1) bcrypt-ruby (3.0.0) builder (3.0.0) bundler (1.0.18) coffee-rails (3.1.0) coffee-script (2.2.0) coffee-script-source (1.1.2) erubis (2.7.0) execjs (1.2.4) hike (1.2.1) i18n (0.6.0) jquery-rails (1.0.13) mail (2.3.0) mime-types (1.16) multi_json (1.0.3) polyglot (0.3.2) rack (1.3.2) rack-cache (1.0.3) rack-mount (0.8.3) rack-ssl (1.3.2) rack-test (0.6.1) rails (3.1.0) railties (3.1.0) rake (0.9.2 ruby) rdoc (3.9.4) sass (3.1.7) sass-rails (3.1.0) sprockets (2.0.0) sqlite3 (1.3.4) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) turn (0.8.2) tzinfo (0.3.29) uglifier (1.0.2) Valmont:~ wmwedel$ cd /Users/wmwedel/RubyRailsProjects/depot Valmont:depot wmwedel$ ls Gemfile README app config.ru doc log script tmp Gemfile.lock Rakefile config db lib public test vendor Valmont:depot wmwedel$ rake db:migrate /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/version.rb:9: warning: already initialized constant VERSION /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:26: warning: already initialized constant RAKEVERSION /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/early_time.rb:17: warning: already initialized constant EARLY /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/alt_system.rb:32: warning: already initialized constant WINDOWS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:28: warning: already initialized constant DEFAULT_RAKEFILES WARNING: Possible conflict with Rake extension: String#ext already exists WARNING: Possible conflict with Rake extension: String#pathmap already exists /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task_arguments.rb:73: warning: already initialized constant EMPTY_TASK_ARGS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/invocation_chain.rb:49: warning: already initialized constant EMPTY /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/dsl_definition.rb:143: warning: already initialized constant Commands /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:44: warning: already initialized constant ARRAY_METHODS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:47: warning: already initialized constant MUST_DEFINE /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:51: warning: already initialized constant MUST_NOT_DEFINE /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:55: warning: already initialized constant SPECIAL_RETURN /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:61: warning: already initialized constant DELEGATING_METHODS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:364: warning: already initialized constant DEFAULT_IGNORE_PATTERNS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/file_list.rb:370: warning: already initialized constant DEFAULT_IGNORE_PROCS /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:64: warning: already initialized constant FileList /Users/wmwedel/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake.rb:65: warning: already initialized constant RakeFileUtils rake aborted! stack level too deep

(See full trace by running task with –trace) Valmont:depot wmwedel$ gem uninstall rake -a

You have requested to uninstall the gem: rake-0.9.2 execjs-1.2.4 depends on [rake (>= 0)] multi_json-1.0.3 depends on [rake (~> 0.9)] rack-1.3.2 depends on [rake (>= 0)] rack-mount-0.8.3 depends on [rake (>= 0)] railties-3.1.0 depends on [rake (>= 0.8.7)] sprockets-2.0.0 depends on [rake (>= 0)] thor-0.14.6 depends on [rake (>= 0.8)] treetop-1.4.10 depends on [rake (>= 0)] If you remove this gems, one or more dependencies will not be met. Continue with Uninstall? [Yn] Y Remove executables: rake

in addition to the gem? [Yn] Y Removing rake Successfully uninstalled rake-0.9.2 Valmont:depot wmwedel$ gem list

** LOCAL GEMS **

actionmailer (3.1.0) actionpack (3.1.0) activemodel (3.1.0) activerecord (3.1.0) activeresource (3.1.0) activesupport (3.1.0) ansi (1.3.0) arel (2.2.1) bcrypt-ruby (3.0.0) builder (3.0.0) bundler (1.0.18) coffee-rails (3.1.0) coffee-script (2.2.0) coffee-script-source (1.1.2) erubis (2.7.0) execjs (1.2.4) hike (1.2.1) i18n (0.6.0) jquery-rails (1.0.13) mail (2.3.0) mime-types (1.16) multi_json (1.0.3) polyglot (0.3.2) rack (1.3.2) rack-cache (1.0.3) rack-mount (0.8.3) rack-ssl (1.3.2) rack-test (0.6.1) rails (3.1.0) railties (3.1.0) rake (0.9.2) rdoc (3.9.4) sass (3.1.7) sass-rails (3.1.0) sprockets (2.0.0) sqlite3 (1.3.4) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) turn (0.8.2) tzinfo (0.3.29) uglifier (1.0.2) Valmont:depot wmwedel$ rake db:migrate == CreateProducts: migrating ================================================= – create_table(:products) -> 0.0011s == CreateProducts: migrated (0.0011s) ========================================

Valmont:depot wmwedel$

It would be useful to understand if this is a rvm problem or something else.

Samr_small_pragsmall
02 Sep 2011, 15:57
Sam Ruby (634 posts)

I’ve reproduced the problem. An alternate solution would be to run bundle exec rake db:migrate. But that’s a pain. One way to eliminate that would be to find the rake script that is generated (by doing which rake), and adding the following line to it:

require 'bundler/setup' if File.exist? 'Gemfile'

This line would go immediately after the require of ‘rubygems’. I’ll keep searching to see if I can find an even better solution.

Samr_small_pragsmall
04 Sep 2011, 14:43
Sam Ruby (634 posts)

Further investigation.

First, yet another solution. Run bundle exec --binstubs from within your Rails application, and then adding the bin directory to the front of your PATH environment variable.

The problem seems to be that “rvm install 1.9.2” installs the rake gem twice:

/home/rubys/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2
/home/rubys/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2

When this occurs, gem list rake produces:

rake (0.9.2 ruby)

Uninstalling either version of the gem will cause gem list rake to produce:

rake (0.9.2)

If you only have one (it doesn’t matter which one) you won’t see this problem. Furthermore, as long as you have at least one, neither gem install rails nor bundle install will install another copy.

The easiest way to delete just one is with the following command (complete with the parentheses):

(rvm use @global; gem uninstall -x rake)
Samr_small_pragsmall
05 Sep 2011, 12:55
Sam Ruby (634 posts)

issue opened: https://github.com/wayneeseguin/rvm/issues/400

Generic-user-small
05 Sep 2011, 18:43
T.J. Zeeman (2 posts)

Thanks for the analysis. The workaround from two posts up (rvm use…) fixed both cli and RubyMine use of rake for me.

I’m running on Snow Leopard 10.6.8 btw.

Samr_small_pragsmall
05 Sep 2011, 23:10
Sam Ruby (634 posts)

… and it looks like we have a fix to the problem committed to RVM: https://github.com/wayneeseguin/rvm/commit/75c42803dd27e0565760b7db344966f69bd26509

Generic-user-small
06 Sep 2011, 14:47
Wally Wedel (8 posts)

Many thanks to Sam and Wayne for promptly investigating and fixing the problem.

Is it time to do an rvm implode and start over to see if the fix and book narrative works?

Samr_small_pragsmall
06 Sep 2011, 15:33
Sam Ruby (634 posts)

Is it time to do an rvm implode and start over to see if the fix and book narrative works?

Sure!

The next eBook release (not current scheduled, but there will likely be an errata and pagination sweep at some point) will also recommend running rake about immediately after listing the directory context in the Instant Gratification chapter, and will point to gemsets and bundle exec as possible solutions to common problems.

Generic-user-small
07 Sep 2011, 14:46
Wally Wedel (8 posts)

All is working well through chapter 7.

The rake about command is a good suggestion.

My only other current suggestion is a reorganization of the accompanying code archive. The rails31 directory is very obscure so it is all too easy to make the mistake of starting off with the wrong code. I would suggest a rails2 and rails 31 directory at the same level so it is obvious that a choice should be made at that level.

Samr_small_pragsmall
08 Sep 2011, 10:13
Sam Ruby (634 posts)

My only other current suggestion is a reorganization of the accompanying code archive.

The primary constraint we have is that we can’t go back in time and update all the books which are out in print. Previously, we didn’t make such a major update without issuing a new edition, instead we documented the changes online.

Certainly a lesson to be learned going forward.

Generic-user-small
08 Sep 2011, 18:08
Wally Wedel (8 posts)

I see your point about continuing to support older editions. I submitted an erratum suggesting adding a bullet to the preface calling attention to the new directory for the code examples. I suspect everyone reads that preface to find out what is new in this edition.

Try_pragsmall
08 Oct 2011, 22:14
Bogdan Kulbida (2 posts)

That is amazing! I worked for me too. Thank you.

Generic-user-small
02 Nov 2011, 16:17
Bradford Cottel (6 posts)

Sam, re: “point to gemsets and bundle exec as possible solutions to common problem” I highly recommend checking out Ryan McGeary’s post “Vendor Everything still applies”:http://ryan.mcgeary.org/2011/02/09/vendor-everything-still-applies/ as a best practice. I’ve got the 4-5 aliases for bundler set up and regularly just type ~~~ be ~~~ before all my commands like ~~~ be rake db:migrate ~~~ and find it’s very satisfying to a) have all my gems with my projects and b) “know” that I’m using those gems and only those gems when running the same.

I find it much better than the relative ‘mess’ I made of things for the previous couple of years trying to use gemsets and having too many of them, not updated, shared between projects, etc. Gemsets are still great for gem development, btw, but for apps, I much prefer Ryan’s solution.

I look forward to getting P2.1 in book form!

You must be logged in to comment