草庐IT

ruby - Mac 10.9.5 安装 Rmagick 失败

coder 2025-06-21 原文

我尝试将 rails 从 4.1.1 升级到 4.2.0,然后安装 Rmagick 时出错。 在升级 rails 之前,Rmagick 在 rails4.1.1 上运行良好。 重装ImageMagick后试了一下,还是报错。

这是我得到的

     sudo gem install rmagick -v 2.13.4
    Building native extensions.  This could take a while...
    ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

        /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
    checking for Ruby version >= 1.8.5... yes
    checking for xcrun... yes
    checking for Magick-config... yes
    checking for ImageMagick version >= 6.4.9... yes
    checking for stdint.h... yes
    checking for sys/types.h... yes
    checking for wand/MagickWand.h... yes
    checking for snprintf() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for AcquireImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for AffinityImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for AffinityImages() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for AutoGammaImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for AutoLevelImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for BlueShiftImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for ColorMatrixImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for ConstituteComponentTerminus() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for DeskewImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for DestroyConstitute() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for EncipherImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for EqualizeImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for EvaluateImages() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for FloodfillPaintImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for FunctionImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for GetAuthenticIndexQueue() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for GetAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for GetImageAlphaChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for GetMagickFeatures() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for GetVirtualPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for LevelImageColors() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for LevelColorsImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for LevelizeImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for LiquidRescaleImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for MagickLibAddendum() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for OpaquePaintImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for QueueAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for RemapImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for RemapImages() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for RemoveImageArtifact() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for RotationalBlurImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for RotationalBlurImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for SelectiveBlurImageChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for SetImageAlphaChannel() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for SetImageArtifact() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for SetMagickMemoryMethods() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for SparseColorImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for StatisticImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for SyncAuthenticPixels() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for TransformImageColorspace() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for TransparentPaintImage() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for TransparentPaintImageChroma() in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... no
    checking for QueryMagickColorname() new signature... yes
    checking for Image.type in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for DrawInfo.kerning in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for DrawInfo.interline_spacing in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for DrawInfo.interword_spacing in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for DitherMethod in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for MagickFunction in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for ImageLayerMethod in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for long double in assert.h,ctype.h,stdio.h,stdlib.h,math.h,time.h,stdint.h,sys/types.h,wand/MagickWand.h... yes
    checking for AlphaChannelType.CopyAlphaChannel... yes
    checking for AlphaChannelType.BackgroundAlphaChannel... yes
    checking for CompositeOperator.BlurCompositeOp... yes
    checking for CompositeOperator.DistortCompositeOp... yes
    checking for CompositeOperator.LinearBurnCompositeOp... yes
    checking for CompositeOperator.LinearDodgeCompositeOp... yes
    checking for CompositeOperator.MathematicsCompositeOp... yes
    checking for CompositeOperator.PegtopLightCompositeOp... yes
    checking for CompositeOperator.PinLightCompositeOp... yes
    checking for CompositeOperator.VividLightCompositeOp... yes
    checking for CompressionType.DXT1Compression... yes
    checking for CompressionType.DXT3Compression... yes
    checking for CompressionType.DXT5Compression... yes
    checking for CompressionType.ZipSCompression... yes
    checking for CompressionType.PizCompression... yes
    checking for CompressionType.Pxr24Compression... yes
    checking for CompressionType.B44Compression... yes
    checking for CompressionType.B44ACompression... yes
    checking for DistortImageMethod.BarrelDistortion... yes
    checking for DistortImageMethod.BarrelInverseDistortion... yes
    checking for DistortImageMethod.BilinearForwardDistortion... yes
    checking for DistortImageMethod.BilinearReverseDistortion... yes
    checking for DistortImageMethod.DePolarDistortion... yes
    checking for DistortImageMethod.PolarDistortion... yes
    checking for DistortImageMethod.PolynomialDistortion... yes
    checking for DistortImageMethod.ShepardsDistortion... yes
    checking for DitherMethod.NoDitherMethod... yes
    checking for FilterTypes.KaiserFilter... yes
    checking for FilterTypes.WelshFilter... yes
    checking for FilterTypes.ParzenFilter... yes
    checking for FilterTypes.LagrangeFilter... yes
    checking for FilterTypes.BohmanFilter... yes
    checking for FilterTypes.BartlettFilter... yes
    checking for FilterTypes.SentinelFilter... yes
    checking for MagickEvaluateOperator.PowEvaluateOperator... yes
    checking for MagickEvaluateOperator.LogEvaluateOperator... yes
    checking for MagickEvaluateOperator.ThresholdEvaluateOperator... yes
    checking for MagickEvaluateOperator.ThresholdBlackEvaluateOperator... yes
    checking for MagickEvaluateOperator.ThresholdWhiteEvaluateOperator... yes
    checking for MagickEvaluateOperator.GaussianNoiseEvaluateOperator... yes
    checking for MagickEvaluateOperator.ImpulseNoiseEvaluateOperator... yes
    checking for MagickEvaluateOperator.LaplacianNoiseEvaluateOperator... yes
    checking for MagickEvaluateOperator.MultiplicativeNoiseEvaluateOperator... yes
    checking for MagickEvaluateOperator.PoissonNoiseEvaluateOperator... yes
    checking for MagickEvaluateOperator.UniformNoiseEvaluateOperator... yes
    checking for MagickEvaluateOperator.CosineEvaluateOperator... yes
    checking for MagickEvaluateOperator.SineEvaluateOperator... yes
    checking for MagickEvaluateOperator.AddModulusEvaluateOperator... yes
    checking for MagickFunction.ArcsinFunction... yes
    checking for MagickFunction.ArctanFunction... yes
    checking for MagickFunction.PolynomialFunction... yes
    checking for MagickFunction.SinusoidFunction... yes
    checking for ImageLayerMethod.FlattenLayer... yes
    checking for ImageLayerMethod.MergeLayer... yes
    checking for ImageLayerMethod.MosaicLayer... yes
    checking for ImageLayerMethod.TrimBoundsLayer... yes
    checking for VirtualPixelMethod.HorizontalTileVirtualPixelMethod... yes
    checking for VirtualPixelMethod.VerticalTileVirtualPixelMethod... yes
    checking for VirtualPixelMethod.HorizontalTileEdgeVirtualPixelMethod... yes
    checking for VirtualPixelMethod.VerticalTileEdgeVirtualPixelMethod... yes
    checking for VirtualPixelMethod.CheckerTileVirtualPixelMethod... yes
    checking for ruby/io.h... yes
    checking for rb_frame_this_func() in ruby.h,ruby/io.h... yes
    creating extconf.h
    creating Makefile


    ======================================================================
    Sat 31Jan15 12:34:19
    This installation of RMagick 2.13.4 is configured for
    Ruby 2.0.0 (universal.x86_64-darwin13) and ImageMagick 
    ======================================================================



    make "DESTDIR="
    compiling rmagick.c
    compiling rmdraw.c
    ~~~~~~~~~~~~~~~~~
compile some files
    ~~~~~~~~~~~~~~~~~
    compiling rminfo.c
    compiling rmmain.c
    rmmain.c:1724:28: error: use of undeclared identifier 'MagickSupport'
        features = rb_str_new2(MagickSupport);
                               ^
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:760:27: note: expanded from macro 'rb_str_new_cstr'
        (__builtin_constant_p(str)) ?               \
                              ^
    rmmain.c:1724:28: error: use of undeclared identifier 'MagickSupport'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:761:14: note: expanded from macro 'rb_str_new_cstr'
            rb_str_new((str), (long)strlen(str)) :  \
                        ^
    rmmain.c:1724:28: error: use of undeclared identifier 'MagickSupport'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:762:18: note: expanded from macro 'rb_str_new_cstr'
            rb_str_new_cstr(str);                   \
                            ^
    rmmain.c:1724:14: error: assigning to 'volatile VALUE' (aka 'volatile unsigned long') from incompatible type 'void'
        features = rb_str_new2(MagickSupport);
                 ^
    4 errors generated.
    make: *** [rmmain.o] Error 1


    Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/rmagick-2.13.4 for inspection.
    Results logged to /Library/Ruby/Gems/2.0.0/gems/rmagick-2.13.4/ext/RMagick/gem_make.out

而且,这些是更多信息。

ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13]


 brew info imagemagick
imagemagick: stable 6.9.0-3 (bottled), HEAD
http://www.imagemagick.org
/usr/local/Cellar/imagemagick/6.9.0-3 (1440 files, 22M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/imagemagick.rb
==> Dependencies
Build: xz ✔, pkg-config ✔
Required: libtool ✔, xz ✔
Recommended: jpeg ✔, libpng ✔, freetype ✔
Optional: fontconfig ✘, libtiff ✘, little-cms ✘, little-cms2 ✘, libwmf ✘, librsvg ✘, liblqr ✘, openexr ✘, ghostscript ✘, webp ✘, fftw ✘
==> Options
--enable-hdri
    Compile with HDRI support
--with-fftw
    Compile with FFTW support
--with-fontconfig
    Build with fontconfig support
--with-ghostscript
    Build with ghostscript support
--with-jp2
    Compile with Jpeg2000 support
--with-liblqr
    Build with liblqr support
--with-librsvg
    Build with librsvg support
--with-libtiff
    Build with libtiff support
--with-libwmf
    Build with libwmf support
--with-little-cms
    Build with little-cms support
--with-little-cms2
    Build with little-cms2 support
--with-openexr
    Build with openexr support
--with-perl
    enable build/install of PerlMagick
--with-quantum-depth-16
    Compile with a quantum depth of 16 bit
--with-quantum-depth-32
    Compile with a quantum depth of 32 bit
--with-quantum-depth-8
    Compile with a quantum depth of 8 bit
--with-webp
    Build with webp support
--with-x11
    Build with x11 support
--without-freetype
    Build without freetype support
--without-jpeg
    Build without jpeg support
--without-libpng
    Build without libpng support
--without-magick-plus-plus
    disable build/install of Magick++
--HEAD
    Install HEAD version

提前致谢

最佳答案

我在使用 rmagick 2.13.4 的 OSX 10.10.2 (Yosemite) 上遇到了同样的错误。 该问题已在最新代码中修复。请参阅下面的问题。

然而,新版本还没有正式发布,所以我用上面的代码在本地修复了这个问题。

$ git clone -b RMagick_2-13-4 git://github.com/gemhome/rmagick.git

合并修复代码(替换ext/RMagick/rmmain.c中的相关代码)。

#if defined(HAVE_GETMAGICKFEATURES)
  // 6.5.7 - latest (7.0.0)
  features = rb_str_new2(GetMagickFeatures());
#elif defined(MagickFeatures)
  // 6.5.7 - latest (7.0.0)
  features = rb_str_new2(MagickFeatures);
#elif defined(MagickSupport)
  // 6.5.5 - 6.5.6
  features = rb_str_new2(MagickSupport);
#else
  features = rb_str_new("unknown",7);
#endif

然后安装它。

$ cd rmagick/
$ gem build rmagick.gemspec
$ gem install --local rmagick-2.13.4.gem 
Building native extensions.  This could take a while...
Successfully installed rmagick-2.13.4
1 gem installed

希望对您有所帮助。

关于ruby - Mac 10.9.5 安装 Rmagick 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28247947/

有关ruby - Mac 10.9.5 安装 Rmagick 失败的更多相关文章

  1. ruby - 如何使用 Nokogiri 的 xpath 和 at_xpath 方法 - 2

    我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div

  2. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

    总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

  3. Ruby 解析字符串 - 2

    我有一个字符串input="maybe(thisis|thatwas)some((nice|ugly)(day|night)|(strange(weather|time)))"Ruby中解析该字符串的最佳方法是什么?我的意思是脚本应该能够像这样构建句子:maybethisissomeuglynightmaybethatwassomenicenightmaybethiswassomestrangetime等等,你明白了......我应该一个字符一个字符地读取字符串并构建一个带有堆栈的状态机来存储括号值以供以后计算,还是有更好的方法?也许为此目的准备了一个开箱即用的库?

  4. ruby - 使用 RubyZip 生成 ZIP 文件时设置压缩级别 - 2

    我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看ruby​​zip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d

  5. ruby - 为什么我可以在 Ruby 中使用 Object#send 访问私有(private)/ protected 方法? - 2

    类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc

  6. ruby-on-rails - 使用 Ruby on Rails 进行自动化测试 - 最佳实践 - 2

    很好奇,就使用ruby​​onrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提

  7. ruby-on-rails - rails : keeping DRY with ActiveRecord models that share similar complex attributes - 2

    这似乎应该有一个直截了当的答案,但在Google上花了很多时间,所以我找不到它。这可能是缺少正确关键字的情况。在我的RoR应用程序中,我有几个模型共享一种特定类型的字符串属性,该属性具有特殊验证和其他功能。我能想到的最接近的类似示例是表示URL的字符串。这会导致模型中出现大量重复(甚至单元测试中会出现更多重复),但我不确定如何让它更DRY。我能想到几个可能的方向...按照“validates_url_format_of”插件,但这只会让验证干给这个特殊的字符串它自己的模型,但这看起来很像重溶液为这个特殊的字符串创建一个ruby​​类,但是我如何得到ActiveRecord关联这个类模型

  8. ruby - 在 Ruby 中使用匿名模块 - 2

    假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于

  9. ruby - 其他文件中的 Rake 任务 - 2

    我试图在一个项目中使用rake,如果我把所有东西都放到Rakefile中,它会很大并且很难读取/找到东西,所以我试着将每个命名空间放在lib/rake中它自己的文件中,我添加了这个到我的rake文件的顶部:Dir['#{File.dirname(__FILE__)}/lib/rake/*.rake'].map{|f|requiref}它加载文件没问题,但没有任务。我现在只有一个.rake文件作为测试,名为“servers.rake”,它看起来像这样:namespace:serverdotask:testdoputs"test"endend所以当我运行rakeserver:testid时

  10. ruby - 如何在 Ruby 中顺序创建 PI - 2

    出于纯粹的兴趣,我很好奇如何按顺序创建PI,而不是在过程结果之后生成数字,而是让数字在过程本身生成时显示。如果是这种情况,那么数字可以自行产生,我可以对以前看到的数字实现垃圾收集,从而创建一个无限系列。结果只是在Pi系列之后每秒生成一个数字。这是我通过互联网筛选的结果:这是流行的计算机友好算法,类机器算法:defarccot(x,unity)xpow=unity/xn=1sign=1sum=0loopdoterm=xpow/nbreakifterm==0sum+=sign*(xpow/n)xpow/=x*xn+=2sign=-signendsumenddefcalc_pi(digits

随机推荐