配置新计算机(Mac OS Mojave-版本10.14.2)。
使用rbenv
安装ruby之后。我正在尝试安装一些gem并运行:
gem install rake bundler rspec rubocop pry pry-byebug hub colored octoki
但是它给了我以下错误:
ERROR: While executing gem ... (TypeError)
incompatible marshal file format (can't be read)
format version 4.8 required; 60.33 given
这是我的宝石环境:
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/elise/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /Users/elise/.rbenv/versions/2.5.3/bin/ruby
- EXECUTABLE DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/bin
- SPEC CACHE DIRECTORY: /Users/elise/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/elise/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
- /Users/elise/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- :benchmark => false
- "gem" => "--no-document"
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
- SHELL PATH:
- /Users/elise/.rbenv/versions/2.5.3/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- ./bin
- ./node_modules/.bin
- /Users/elise/.rbenv/shims
- /Users/elise/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/sbin
有人知道此错误来自何处吗? 感谢您的帮助。
答案 0 :(得分:2)
您仅在gem配置中启用了非常老的(而不是维护的)远程gem源。这可能是由于某些旧的迁移配置或遵循一些过时且过时的建议所致。
要解决此问题,您首先需要删除过时的宝石资源,然后添加当前应该使用的唯一宝石资源。为此,您可以从终端运行以下命令:
gem sources --remove http://gems.github.com/
gem sources --remove http://gems.rubyforge.org/
gem sources --add https://rubygems.org/
答案 1 :(得分:1)
您必须删除拥有的所有宝石资源,并添加https://rubygems.org/。请注意,http://gems.rubyforge.org/和http://gems.github.com已永久死亡,应将其删除。您可以运行以下命令列出来源:
<div id="app">
<div>
<label for="name">Name</label>
<input type="text" @keypress="checkField" v-model="name">
<span v-if="checkName">Checks out </span>
<span v-if="!checkName">Pleas enter valid name</span>
</div>
<div>
<label for="Age">Age</label>
<input type="number" @keypress="checkField2" v-model="age">
<span v-if="checkAge">Enter Valid Age </span>
<span v-if="!checkAge">Not a valid age</span>
</div>
<div>
<select name="" id="">
<option disabled selected>Please Choose</option>
<option v-for="gender in genders" :value="gender">
{{gender}}
</option>
</select>
<span v-if="genderField">Please select a gender</span>
<span v-if="!genderField">Green means go</span>
</div>
<div>
<button @click="checkSubmit(e)">Submit</button>
</div>
</div>
您应该得到这样的东西:
data: {
name: "",
checkName: "",
age: "",
checkAge: "",
genders : ["Male",'Female',"Other"],
genderField: ""
},
methods: {
checkField() {
if (!this.amount) {
this.checkName = true
}
},
checkGender() {
if(!this.genders){
this.genderField = true
}
},
checkSubmit(e){
//check if all fields are filled before submitting
alert("it is working")
e.preventDefault()
}
}
})
1)删除所有来源:
gem sources
2)添加正确的来源:
*** CURRENT SOURCES ***
//gems.rubyforge.org/
//gems.github.com
此外,从不 gem sources -r http://gems.rubyforge.org/
gem sources -r http://gems.github.com
希望这会有所帮助!