当我运行bundle install时,我在安装调试器gem(1.6.6)时遇到错误.我正在使用ruby 2.1.1和rails 4.0.4.我对rails很新,不知道是什么导致了这个问题.
错误
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
Makefile creation failed
*************************************************************
NOTE: If your headers were not found, try passing
--with-ruby-include=PATH_TO_HEADERS
*************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably …Run Code Online (Sandbox Code Playgroud) 在我开始使用rails dev之前,我正在尝试更深入地学习ruby,但是我在学习课程时遇到了一些问题.我似乎无法理解为什么以下不起作用.
#point.rb
class Point
attr_accessor :x, :y
def initialize(p = [0,0])
@x = p[0]
@y = p[1]
end
end
#shape.rb
require_relative 'point.rb'
class Shape
attr_accessor :points
def initialize *the_points
for p in the_points
@points.append Point.new(p)
end
end
end
s = Shape.new([3,2])
puts s.points
Run Code Online (Sandbox Code Playgroud)
当我调用该函数时,我得到NilClass的no方法错误,我假设它是指@ point.append.
puts "Hello! Reading temperature value from data file..."
num = File.read("temp.dat")
puts "The number is #{num}..."
celsius = num.to_i
fahrenheit = (celsius.to_i * 9 / 5) + 32
puts "The Fahrenheit value is: #{ fahrenheit }."
Run Code Online (Sandbox Code Playgroud)
在第三行中,块...之后#{num}以新行打印.我的印象是使用该块将参数传递给显示器,以便更容易格式化.
为什么点到了新的一行?
我写了一个小程序来测试Textmate 2(我对Ruby很新),并且由于某些原因它正在吐出4 + 9 = 49而不是13.
def add(x,y)
c = x + y
return c
end
puts "please enter a value "
a = gets.chomp
puts "please enter another value "
b = gets.chomp
printMe = add(a,b)
puts printMe
Run Code Online (Sandbox Code Playgroud)