在OSX错误上安装Mysql gem - 'Marshal data too short'

时间:2009-08-02 22:16:31

标签: ruby-on-rails macos

尝试在OSX上安装mysql gem时出现'marshal data too short'错误。我已经听到了清除.gems的建议,但似乎无法在系统上找到它。有人可以提供帮助吗?

apple$ sudo gem install mysql --backtrace --debug
Exception `NameError' at /Library/Ruby/Site/1.8/rubygems/command_manager.rb:161 - uninitialized constant Gem::Commands::InstallCommand
Exception `Gem::LoadError' at /Library/Ruby/Site/1.8/rubygems.rb:826 - Could not find RubyGem test-unit (>= 0)

Exception `ArgumentError' at /Library/Ruby/Site/1.8/rubygems/spec_fetcher.rb:111 - marshal data too short
ERROR:  While executing gem ... (ArgumentError)
    marshal data too short
    /Library/Ruby/Site/1.8/rubygems/spec_fetcher.rb:111:in `load'
    /Library/Ruby/Site/1.8/rubygems/spec_fetcher.rb:111:in `fetch_spec'
    /Library/Ruby/Site/1.8/rubygems/spec_fetcher.rb:71:in `fetch'
    /Library/Ruby/Site/1.8/rubygems/spec_fetcher.rb:70:in `map'
    /Library/Ruby/Site/1.8/rubygems/spec_fetcher.rb:70:in `fetch'
    /Library/Ruby/Site/1.8/rubygems/dependency_installer.rb:99:in `find_gems_with_sources'
    /Library/Ruby/Site/1.8/rubygems/dependency_installer.rb:192:in `find_spec_by_name_and_version'
    /Library/Ruby/Site/1.8/rubygems/dependency_installer.rb:213:in `install'
    /Library/Ruby/Site/1.8/rubygems/commands/install_command.rb:118:in `execute'
    /Library/Ruby/Site/1.8/rubygems/commands/install_command.rb:115:in `each'
    /Library/Ruby/Site/1.8/rubygems/commands/install_command.rb:115:in `execute'
    /Library/Ruby/Site/1.8/rubygems/command.rb:257:in `invoke'
    /Library/Ruby/Site/1.8/rubygems/command_manager.rb:132:in `process_args'
    /Library/Ruby/Site/1.8/rubygems/command_manager.rb:102:in `run'
    /Library/Ruby/Site/1.8/rubygems/gem_runner.rb:58:in `run'
    /usr/bin/gem:21

3 个答案:

答案 0 :(得分:3)

我的Windows机器上出现了同样的错误,如果我要使用gem。

ERROR:  While executing gem ... (ArgumentError)    
marshal data too short

删除gem缓存目录“c:\ Documents and Settings \ MyUser \ .gem”为我工作。 即使重新安装ruby,似乎也会保存一些数据。可能是缓存的文件已损坏。

答案 1 :(得分:0)

尝试使用以下命令。在OS X中提供mysql目录的位置。

sudo gem install mysql - --with-mysql-dir = / usr / local / mysql

http://hivelogic.com/articles/installing-mysql-on-mac-os-x/

如果未正确安装,请检查在Mac OSX上安装Mysql的链接。

祝你好运!

答案 2 :(得分:0)

此外,.gem目录位于您的主目录中:/Users/yourname/.gem

希望有所帮助。