Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7322 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

rake freeze gems task fails

Reported by: hasmanyjosh Assigned to: core
Priority: high Milestone: 1.2
Component: Railties Version:
Severity: major Keywords: rake freeze gems patch
Cc: chrismear, djwonk, hasmanyjosh, matt

Description

Since upgrading to Rails 1.2.1 and Rubygems 0.9.1, freezing gems doesn't work.

> rake rails:freeze:gems --trace
(in /Users/josh/rails/slack)
/Users/josh/rails/slack/config/boot.rb:29:Warning: require_gem is obsolete.  Use gem instead.
** Invoke rails:freeze:gems (first_time)
** Execute rails:freeze:gems
Freezing to the gems for Rails 1.2.1
rm -rf vendor/rails
mkdir -p vendor/rails
cd vendor/rails
ERROR:  While executing gem ... (ArgumentError)
    install directory "activesupport-1.4.0" not absolute
rake aborted!
exit
/usr/local/lib/ruby/site_ruby/1.8/rubygems/user_interaction.rb:171:in `exit'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/user_interaction.rb:171:in `terminate_interaction'
(eval):3:in `terminate_interaction'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:95:in `run'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:30:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/tasks/framework.rake:26
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/tasks/framework.rake:25:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/tasks/framework.rake:25
/usr/local/lib/ruby/1.8/fileutils.rb:121:in `chdir'
/usr/local/lib/ruby/1.8/fileutils.rb:121:in `chdir'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:812:in `chdir'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/tasks/framework.rake:24
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke'
/usr/local/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/usr/local/bin/rake:16:in `load'
/usr/local/bin/rake:16
> ruby --version
ruby 1.8.5 (2006-08-25) [i686-darwin8.8.1]
> gem --version
0.9.1
> rails --version
Rails 1.2.1

Since Rubygems 0.9.1 changed some stuff about how pathnames operate, maybe the rake task needs to be updated.

Attachments

rails_freeze.patch (490 bytes) - added by ceefour on 08/04/07 08:43:13.

Change History

(follow-up: ↓ 2 ) 01/23/07 07:56:48 changed by hasmanyjosh

  • status changed from new to closed.
  • resolution set to invalid.

Ah, I spoke too soon. This appears to be a bug in Rubygems:

http://rubyforge.org/tracker/index.php?func=detail&aid=8063&group_id=126&atid=575

(in reply to: ↑ 1 ; follow-up: ↓ 6 ) 01/25/07 21:12:09 changed by eljay

  • status changed from closed to reopened.
  • resolution deleted.

After a little bit more investigation and a discussion with Eric Hodel (Rubygems developer) the bug is actually both in Rubygems 0.9.1 AND in Rails 1.2.

According to Eric Hodel the freeze task should be using the installer to unpack, rather than hacking through the #unpack command.

Installer.new(gem).unpack(dest_dir)

is the proper way od unpacking the gem in the vendor/rails directory.

02/01/07 16:16:46 changed by chrismear

  • cc set to chrismear.

02/12/07 07:08:06 changed by djwonk

FWIW, I am also experiencing this error with Rails 1.2.2 (gem) and gem 0.9.1

$ rake rails:freeze:gems --trace
/opt/local/bin/rake:17:Warning: require_gem is obsolete.  Use gem instead.
(in /Users/david/dev/rails_1.2.2)
** Invoke rails:freeze:gems (first_time)
** Execute rails:freeze:gems
Freezing to the gems for Rails 1.2.2
rm -rf vendor/rails
mkdir -p vendor/rails
cd vendor/rails
ERROR:  While executing gem ... (ArgumentError)
    install directory "activesupport-1.4.1" not absolute
rake aborted!
exit
...

02/12/07 07:08:42 changed by djwonk

  • cc changed from chrismear to chrismear, djwonk.

(in reply to: ↑ 2 ) 02/12/07 12:42:25 changed by bitsweat

  • status changed from reopened to closed.
  • resolution set to invalid.

Replying to eljay:

After a little bit more investigation and a discussion with Eric Hodel (Rubygems developer) the bug is actually both in Rubygems 0.9.1 AND in Rails 1.2. According to Eric Hodel the freeze task should be using the installer to unpack, rather than hacking through the #unpack command.

Eric's wrong. Installer#unpack is too low-level to be publicly useful in this scenario (it takes a path to the cached .gem file). The public, stable UnpackCommand worked correctly until now. Please open a new ticket when RubyGems provides a simple my_gem.unpack(dir).

05/11/07 01:51:12 changed by ceefour

  • status changed from closed to reopened.
  • resolution deleted.

This is what I get:

may:~# rails try
      create
      create  app/controllers
      create  app/helpers
...
      create  log/production.log
      create  log/development.log
      create  log/test.log
may:~# cd try
may:~/try# rails -v
Rails 1.2.3
may:~/try# rake rails:freeze:gems
(in /root/try)
Freezing to the gems for Rails 1.4
rm -rf vendor/rails
mkdir -p vendor/rails
cd vendor/rails
Unpacked gem: 'activerecord-1.15.3'
mv activerecord-1.15.3 activerecord
ERROR:  Gem 'rails' not installed.
rake aborted!
undefined method `to_str' for nil:NilClass

(See full trace by running task with --trace)
may:~/try# gem -v
0.9.2

It still doesn't work?

05/11/07 01:53:30 changed by ceefour

Here's the same attempt with --trace:

may:~/try# rm -rf vendor/rails
may:~/try# rake rails:freeze:gems --trace
(in /root/try)
** Invoke rails:freeze:gems (first_time)
** Execute rails:freeze:gems
Freezing to the gems for Rails 1.4
rm -rf vendor/rails
mkdir -p vendor/rails
cd vendor/rails
Unpacked gem: 'activerecord-1.15.3'
mv activerecord-1.15.3 activerecord
ERROR:  Gem 'rails' not installed.
rake aborted!
undefined method `to_str' for nil:NilClass
/usr/lib/ruby/1.8/fileutils.rb:1389:in `fu_each_src_dest0'
/usr/lib/ruby/1.8/fileutils.rb:1375:in `fu_each_src_dest'
/usr/lib/ruby/1.8/fileutils.rb:489:in `mv'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/framework.rake:31
/usr/lib/ruby/1.8/fileutils.rb:121:in `chdir'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:816:in `chdir'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/framework.rake:24
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:399:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:399:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:369:in `invoke'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:362:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1935:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1935:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/bin/rake:7
/usr/bin/rake:16

07/03/07 01:27:34 changed by matt

  • status changed from reopened to closed.
  • resolution set to fixed.

fixed in RubyGems 0.9.2 (tested with rubygems 0.9.2 and Rails 1.2.3)

07/03/07 02:15:47 changed by ceefour

  • status changed from closed to reopened.
  • resolution deleted.

I'm not sure if it works with Gems 0.9.2. But if it did, it doesn't in 0.9.4:

      create  log/development.log
      create  log/test.log
ceefour@ojalanow:/media/prestige/home/ceefour$ cd boo
ceefour@ojalanow:/media/prestige/home/ceefour/boo$ rake rails:freeze:gems
(in /media/prestige/home/ceefour/boo)
Freezing to the gems for Rails 1.4
rm -rf vendor/rails
mkdir -p vendor/rails
cd vendor/rails
Unpacked gem: 'activerecord-1.15.3'
mv activerecord-1.15.3 activerecord
ERROR:  Gem 'rails' not installed.
rake aborted!
undefined method `to_str' for nil:NilClass

(See full trace by running task with --trace)
ceefour@ojalanow:/media/prestige/home/ceefour/boo$ gem -v
0.9.4
ceefour@ojalanow:/media/prestige/home/ceefour/boo$ rails -v
Rails 1.2.3
ceefour@ojalanow:/media/prestige/home/ceefour/boo$ gem list | grep -E '^rails|^active|^action'
actionmailer (1.3.3)
actionpack (1.13.3)
actionwebservice (1.2.3)
activerecord (1.15.3)
activesupport (1.4.2)
rails (1.2.3)
rails-app-installer (0.2.0)
railsbench (0.9.2)

07/03/07 02:17:21 changed by ceefour

I'm _really_ curious about this line:

Freezing to the gems for Rails 1.4

Is there such thing as Rails 1.4 ? If not, why is it reporting as such?

Perhaps this is the problem?

07/03/07 02:44:21 changed by matt

It's weird that it's trying to freeze rails 1.4 can you please post the details of your project like such:

ruby script/about
About your application's environment
Ruby version                 1.8.6 (i686-darwin8.9.1)
RubyGems version             0.9.2
Rails version                1.2.3
Active Record version        1.15.3
Action Pack version          1.13.3
Action Web Service version   1.2.3
Action Mailer version        1.3.3
Active Support version       1.4.2
Edge Rails revision          unknown
Application root             /Users/Matt/rails_projects/test
Environment                  development
Database adapter             mysql
Database schema version      10

(follow-up: ↓ 14 ) 07/03/07 03:20:48 changed by ceefour

  • cc changed from chrismear, djwonk to chrismear, djwonk, hasmanyjosh, matt.

First of all the failing rake rails:freeze:gems left the project in a non-working state.

ceefour@ojalanow:/media/prestige/home/ceefour/boo$ ruby script/about
./script/../config/boot.rb:16:in `require': no such file to load -- script/../config/../vendor/rails/railties/lib/initializer (LoadError)
        from ./script/../config/boot.rb:16
        from script/about:2:in `require'
        from script/about:2

But it's easy to resolve the problem, like always:

ceefour@ojalanow:/media/prestige/home/ceefour/boo$ rm -rf vendor/rails
ceefour@ojalanow:/media/prestige/home/ceefour/boo$ ruby script/about
About your application's environment
Ruby version                 1.8.5 (i486-linux)
RubyGems version             0.9.4
Rails version                1.2.3
Active Record version        1.15.3
Action Pack version          1.13.3
Action Web Service version   1.2.3
Action Mailer version        1.3.3
Active Support version       1.4.2
Application root             /media/prestige/home/ceefour/boo
Environment                  development
Database adapter             mysql

The "boo" project is a fresh "rails boo" without any manual change whatsoever. On Ubuntu Feisty 7.04:

ceefour@ojalanow:/media/prestige/home/ceefour/boo$ uname -a
Linux ojalanow 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32 UTC 2007 i686 GNU/Linux

By the way Matt, I wonder why you're using Rubygems 0.9.2 ? Is there any issue with 0.9.3 or 0.9.4 that prevents it from working properly with Rails/etc.? I'd recommend "gem update --system" since it'd bring a lot of things more inline with what people are using right now. (I also have a curiousity if this might be a Rubygems-specific issue... It's better to say "it's fixed in the newest version" rather than "it _was_ fixed in the old version, but it's not working in the latest stable version") (made me remember the SWIG/Subversion-python issue)

(in reply to: ↑ 13 ) 07/03/07 03:29:34 changed by matt

Replying to ceefour:

By the way Matt, I wonder why you're using Rubygems 0.9.2 ? Is there any issue with 0.9.3 or 0.9.4 that prevents it from working properly with Rails/etc.? I'd recommend "gem update --system" since it'd bring a lot of things more inline with what people are using right now. (I also have a curiousity if this might be a Rubygems-specific issue... It's better to say "it's fixed in the newest version" rather than "it _was_ fixed in the old version, but it's not working in the latest stable version")

I should have said it was fixed in 0.9.2, sorry about that. I'm using 0.9.2 because I'm using macPorts on Mac http://www.macports.org/. Last time I checked, that was the latest version macPorts and I didn't have any issues with it. I'm also changing laptop soon and I didn't bother trying to update.

A lot of Rails developers are on mac (not to say most, but if you were at the RailsConf, you know what I mean) and a lot of us use macPorts, I should probably check what's the latest version available via macPorts and give it a try.

08/04/07 08:43:13 changed by ceefour

  • attachment rails_freeze.patch added.

08/04/07 08:44:10 changed by ceefour

  • keywords changed from rake freeze gems to rake freeze gems patch.
  • priority changed from normal to high.
  • severity changed from normal to major.

Fix/patch attached.

Internal description:

The rake task uses Gem.cache.search to search 'rails', however this is a partial search which leads to, in my case, 'odbc-rails' gem that has version 1.4. Since there is no Rails 1.4, the task fails.

I marked this as Critical because it has effectively blocked me from using Rails freeze feature for several months already! 'odbc-rails' is "innocently causing" the problem in my system, but any gem having 'rails' in its name has the potential to trigger this bug.

ceefour@ojalanow:/media/prestige/home/ceefour/tmp/halo$ rake rails:freeze:gems
(in /media/prestige/home/ceefour/tmp/halo)
Freezing to the gems for Rails 1.4
rm -rf vendor/rails
mkdir -p vendor/rails
cd vendor/rails
Unpacked gem: 'activerecord-1.15.3.7116'
mv activerecord-1.15.3.7116 activerecord
ERROR:  Gem 'rails' not installed.
rake aborted!
undefined method `to_str' for nil:NilClass

(See full trace by running task with --trace)

Workaround:

I fixed the task to specify a strict regex specifying /rails$/i so that rails, and only Rails, will be found by the search. I included 'i' regex modifier in the speculation that other OS (MS's) may somehow use capitalized gem name (???). It's otherwise purely harmless.

08/04/07 16:20:11 changed by kampers

  • status changed from reopened to closed.
  • resolution set to fixed.

This was fixed in [7233]. Try it out with the latest edge rails.

If I'm wrong and there's still a problem, feel free to re-open. Thanks.

08/05/07 03:19:15 changed by kampers

Also, if you experienced this with 1.2.x, koz just fixed it for the stable branch. See [7277].