基本上代码都没怎么修改过,一下就跑起来了。
@huacnlee rails 是 3.1.12 么?怎么解决的 iconv 的依赖?我这边切换到 2.0 就会报 iconv 的依赖的错,来自那个 activesupport.
#32 楼 @pzgz 我在 mac 下开发可以,但是部署到 ubuntu 总是报错,github 上有人提了一个 em 的 issue。https://github.com/eventmachine/eventmachine/issues/389
弱弱问一下。。我用 rvm 下载了 ruby-2.0.0 之后,打gem -v
会出现这个提示……
ERROR: Your gem push credentials file located at:
/home/hegwin/.gem/credentials
has file permissions of 0664 but 0600 is required.
You should reset your credentials at:
https://rubygems.org/profile/edit
if you believe they were disclosed to a third party.
这二者间有什么联系么。。
P.S. 我改过文件权限就好了……为什么以前不需要呢……
说到 python3000 让我想到一个段子
「听好儿子,要提出目标,但不可盲目追随它」「我明白了爸爸,就像 Python 那样提出『只采用唯一正确的方法』那样的目标,实际上却存在 2、3 版本的不兼容」「住口!」「urllib 和 urllib2」「住口!!!」 #译自日语推
附上日语(不知道是不是真的原文
「いいか息子よ.目標を掲げ,しかしその目標に囚われ過ぎないに.」「はいお父さん.つまり Python のように『誰もが正しいと考える,たった 1 つの方法をできる限り採用する』という目標を掲げつつ実際には 2 と 3 という非互換な」「やめろ!」「urllib と urllib2」「やめろ!!!」
Installing darkfish documentation for builder-3.1.4
ERROR: While executing gem ... (RDoc::Error)
error generating /home/ray/.rvm/gems/ruby-2.0.0-p0/doc/builder-3.1.4/rdoc/doc/releases/builder-2_0_0_rdoc.html: U+201C from UTF-8 to US-ASCII (Encoding::UndefinedConversionError)
不知道这是什么问题呢?bundle 不起来。
在自己机器上装了 Ruby 2.0,跑了一下,rails s 和 rails c 都快了 2 秒左右,1.9.3 下 rails c 大概 9 秒,2.0 花 7 秒。
用 thin 跑 faye 也没问题(只是启动起来了,具体的没测)。
目前发现的问题就是 gem -v 挂了……也没查到啥原因
Error loading RubyGems plugin "/Users/david/.rvm/gems/ruby-2.0.0-p0/gems/yard-0.8.3/lib/rubygems_plugin.rb": cannot load such file -- rubygems/doc_manager (LoadError)
2.0.0
我在学习《R 和 RUBY 数据分析之旅第 3 章》,代码如下:
class Restroom
attr_reader :queue
attr_reader :facilities
def initialize(facilities_per_restroom=3)
@queue=[]
@facilities=[]
@facilities_per_restroom.times{@facilities<<Facility.new}
end
def enter(person)
[email protected]{|facility| not facility.occupied?}
if unoccupied_facility
unoccupied_facility.occupy person
else
@queue<<person
end
end
def tick
@facilities.each{|f| f.tick}
end
end
# class Restroom
class Facility
def initialize
@occupier = nil
@duration = 0
end
def occupy(person)
unless occupied?
@occupier = person
@duration =1
Person.population.delete person
true
else
false
end
end
def occupied?
not @occupier.nil?
end
def vacate
Person.population<<@occupier
@occupier = nil
end
def tick
if occupied? and @duration > @occupier.use_duration
vacate
@duration = 0
elseif occupied?
@duration +=1
end
end
end
# class Facility
class Person
@@population = []
attr_reader :use_duration
attr_accessor :frequency
def initialize(frequency=4,use_duration=1)
@frequency= frequency
@use_duration=use_duration
end
def self.population
@@population
end
def need_to_go?
rand(DURATION)+1<=@frequenty
end
end
# class Person
require 'csv'
frequency=3
facilities_per_restroom=3
use_duration=1
population_range=10..600
data={}
population_range.step(10).each do |population_size|
Person.population.clear
population_size.times{Person.population<<Person.new(frequency,use_duration)}
data[population_size]=[]
restroom=Restroom.new facilities_per_restroom
DURATION.times do |t|
data[population_size]<<restroom.queue.size
queue=restroom.queue.clone
restroom.queue.clear
unless queue.empty
restroom.enter queue.shift
end
Person.population.each do |person|
if person.need_to_do
restroom.enter person
end
end
restroom.tick
end
end
CSV.open('simulation1.csv','w') do |csv|
lbl=[]
population_range.step(10).each{|population_size|lbl<<population_size}
csv<<lbl
DURATION.time do |t|
row =[]
population_range.step(10).each do |population_size|
row <<data[population_size][t]
end
csv <<row
end
end
运行结果如下:
restroom.rb:90:in `step': no block given (LocalJumpError)
from restroom.rb:90
第90行:population_range.step(10).each do |population_size|
哪里错了,请指点!
#75 楼 @QueXuQ 我的 yard-0.8.3 也是出现了同样的问题,卸载了当前的 yard 然后重新安装了当前最新版 yard-0.8.76 就 OK 了。
--- rails_projects/genghis » gem -v
Error loading RubyGems plugin "/Users/HuangKai/.rvm/gems/ruby-2.1.5/gems/yard-0.8.3/lib/rubygems_plugin.rb": cannot load such file -- rubygems/doc_manager (LoadError)
2.4.5
--- rails_projects/genghis » gem uninstall yard -v 0.8.3
Error loading RubyGems plugin "/Users/HuangKai/.rvm/gems/ruby-2.1.5/gems/yard-0.8.3/lib/rubygems_plugin.rb": cannot load such file -- rubygems/doc_manager (LoadError)
Remove executables:
yard, yardoc, yri
in addition to the gem? [Yn] y
Removing yard
Removing yardoc
Removing yri
Successfully uninstalled yard-0.8.3
--- rails_projects/genghis » gem install yard
Fetching: yard-0.8.7.6.gem (100%)
Successfully installed yard-0.8.7.6
1 gem installed
--- rails_projects/genghis » gem -v
2.4.5